How ramendr/ramen works
Purpose and runtime entry points
Ramen is a Go-based Kubernetes/OCM operator for disaster recovery across paired managed clusters. It reconciles custom resources to protect workloads and persistent data, then coordinates planned relocation or unplanned failover. The controller-manager binary starts at cmd/main.go; its API contract is defined in api/v1alpha1/. It is deployed in distinct hub and DR-cluster roles through config/hub/manager/kustomization.yaml and config/dr-cluster/manager/kustomization.yaml.
API and desired-state boundary
Ramen’s alpha CRDs express topology, policy, placement orchestration, cluster configuration, maintenance state, and data-protection objects. Key resources include DRCluster, DRPolicy, DRPlacementControl (DRPC), and VolumeReplicationGroup (VRG), defined in:
• api/v1alpha1/drcluster_types.go
• api/v1alpha1/drpolicy_types.go
• api/v1alpha1/drplacementcontrol_types.go
• api/v1alpha1/volumereplicationgroup_types.go
Generated/installable API surfaces are under config/crd/bases/ and samples under config/samples/.
Hub-side orchestration
The hub reconciles DR cluster inventory/configuration and policy validity, then uses DRPC to turn an OCM placement plus DR policy into a chosen primary cluster and recovery workflow. Primary controllers are:
• internal/controller/drcluster_controller.go
• internal/controller/drclusterconfig_controller.go
• internal/controller/drpolicy_controller.go
• internal/controller/drplacementcontrol_controller.go
DRPC has specialized global, VolSync, watcher, network-mapping, and dry-run paths (internal/controller/drplacementcontrol_global.go, internal/controller/drplacementcontrolvolsync.go, internal/controller/drpc_networkmapping.go). This is the control-plane boundary between OCM placement decisions and per-cluster protection actions.
Managed-cluster protection engine
VRG is the managed-cluster execution unit: it selects PVCs, establishes protection state, reports status, and drives promotion/demotion during failover or relocation. Its main reconciler and strategy modules are:
• internal/controller/volumereplicationgroup_controller.go
• internal/controller/vrg_volrep.go
• internal/controller/vrg_volgrouprep.go
• internal/controller/vrg_volsync.go
The control flow is policy/placement → DRPC decision → VRG desired state on participating clusters → replication and workload readiness/status returned to the hub.
Replication and workload-protection adapters
Ramen isolates backend-specific mechanisms behind controller modules:
• CSI-addons VolumeReplication/VolumeGroupReplication for vendor-assisted replication: internal/controller/vrg_volrep.go, internal/controller/vrg_volgrouprep.go.
• VolSync snapshot/rsync protection and secret propagation: internal/controller/volsync/vshandler.go, internal/controller/volsync/secret_propagator.go.
• CephFS consistency-group replication: internal/controller/cephfscg/cghandler.go, internal/controller/cephfscg/replicationgroupsource.go.
• Velero request construction for discovered Kubernetes objects: internal/controller/kubeobjects/velero/requests.go.
• Recipe and lifecycle hooks for application-aware capture/recovery: internal/controller/vrg_recipe.go, internal/controller/hooks/hooks_factory.go.
These adapters are external-service boundaries; the operator creates and observes their Kubernetes APIs rather than implementing storage replication itself.
Platform integrations and operational boundary
Ramen depends on Kubernetes controller-runtime, OCM managed-cluster/placement resources, CSI-addons, and optionally Argo CD ApplicationSets, Velero, VolSync, Ceph/ODF, and S3-compatible object storage. S3 access is encapsulated in internal/controller/s3utils.go and internal/controller/s3_store_accessors.go. RBAC and leader-election permissions are packaged in config/rbac/; monitoring is exposed through config/prometheus/.
Packaging and validation
Kustomize assembles hub and managed-cluster deployments, CRDs, RBAC, certificates, and OLM artifacts (config/hub/, config/dr-cluster/, config/olm-install/). The container build is rooted at Dockerfile. Multi-cluster end-to-end execution is a separate Go harness in e2e/, while test/drenv/ provisions local/external DR environments and integrations such as MinIO, OCM, Velero, VolSync, and Rook/Ceph.
Main entry points: volumereplicationgroup_controller.go VRG reconciler · main.go Controller manager · drplacementcontrol_controller.go DRPC orchestration · drcluster_controller.go Cluster and policy reconcilers
Components 16
API and deployment
- Controller manager · Runs reconciler sets in hub or DR-cluster deployment roles.
cmd/main.go - DR custom resources · DRCluster, DRPolicy, DRPC, and VRG desired-state contract.
- Installable CRDs
- Hub deployment
config/hub/manager/kustomization.yaml - DR-cluster deployment
config/dr-cluster/manager/kustomization.yaml - RBAC and monitoring
Hub control plane
- Cluster and policy reconcilers · Maintains DR inventory, configuration, and policy validity.
internal/controller/drcluster_controller.go - DRPC orchestration · Converts OCM placement and DR policy into primary-cluster and recovery actions.
internal/controller/drplacementcontrol_controller.go - OCM placement
Managed-cluster engine
- VRG reconciler · Selects PVCs, drives protection state, and reports failover readiness.
internal/controller/volumereplicationgroup_controller.go
Protection adapters
- CSI replication · Uses CSI-addons VolumeReplication and VolumeGroupReplication APIs.
internal/controller/vrg_volrep.go - VolSync protection · Handles snapshot/rsync protection and secret propagation.
internal/controller/volsync/vshandler.go - CephFS consistency groups
internal/controller/cephfscg/cghandler.go - Velero object protection · Builds backup and recovery requests for discovered Kubernetes objects.
internal/controller/kubeobjects/velero/requests.go - Recipes and lifecycle hooks · Provides application-aware capture and recovery hooks.
internal/controller/vrg_recipe.go - S3 object storage
internal/controller/s3utils.go
Connections 20
- Hub deployment → Controller manager: deploys
- DR-cluster deployment → Controller manager: deploys
- Controller manager → DR custom resources: watches and updates
- Installable CRDs → DR custom resources: installs schema for
- Controller manager → Cluster and policy reconcilers: runs on hub
- Controller manager → DRPC orchestration: runs on hub
- Controller manager → VRG reconciler: runs on DR clusters
- Cluster and policy reconcilers → DRPC orchestration: validates inventory and policy
- DR custom resources → DRPC orchestration: DRPC and policy desired state
- OCM placement → DRPC orchestration: placement decisions
- DRPC orchestration → VRG reconciler: propagates protection actions
- VRG reconciler → DRPC orchestration: returns readiness and status
- VRG reconciler → CSI replication: promotes, demotes, replicates
- VRG reconciler → VolSync protection: drives snapshot and rsync
- VRG reconciler → CephFS consistency groups: drives consistency groups
- VRG reconciler → Velero object protection: protects Kubernetes objects
- VRG reconciler → Recipes and lifecycle hooks: runs application lifecycle
- VolSync protection → S3 object storage: stores replication data
- VRG reconciler → S3 object storage: accesses protection artifacts
- RBAC and monitoring → Controller manager: authorizes and monitors