Skip to main content

Custom Resource Reference

DR-Syncer uses Custom Resource Definitions (CRDs) to configure and control its behavior. This page provides a comprehensive reference for all available fields and their purposes.

RemoteCluster​

The RemoteCluster CRD defines connection details and authentication for a remote Kubernetes cluster.

apiVersion: dr-syncer.io/v1alpha1
kind: RemoteCluster
metadata:
name: dr-cluster
spec:
kubeconfigSecret: dr-cluster-kubeconfig
sshKeySecret: dr-cluster-ssh-key
agentDeployment:
image: supporttools/dr-syncer-agent:latest
resources:
limits:
cpu: "100m"
memory: "128Mi"
requests:
cpu: "50m"
memory: "64Mi"
status:
phase: Ready
lastConnectionTime: "2025-03-08T15:30:00Z"
agentStatus:
deployed: true
readyReplicas: 3
observedGeneration: 1
conditions:
- type: Ready
status: "True"
lastTransitionTime: "2025-03-08T15:30:00Z"
reason: ConnectionEstablished
message: "Successfully connected to remote cluster"

RemoteCluster Spec Fields​

FieldTypeDescriptionRequired
kubeconfigSecretStringName of the Secret containing the kubeconfig file for accessing the remote clusterYes
sshKeySecretStringName of the Secret containing SSH keys for PVC data replicationNo
agentDeploymentObjectConfiguration for the agent DaemonSet deployed on the remote clusterNo
agentDeployment.imageStringContainer image for the agentNo
agentDeployment.resourcesObjectResource requests and limits for the agentNo

RemoteCluster Status Fields​

FieldTypeDescription
phaseStringCurrent phase of the remote cluster connection (Pending, Ready, Failed)
lastConnectionTimeDateTimeTimestamp of the last successful connection
agentStatusObjectStatus of the agent deployment
agentStatus.deployedBooleanWhether the agent has been deployed
agentStatus.readyReplicasIntegerNumber of ready agent replicas
agentStatus.observedGenerationIntegerThe observed generation of the agent DaemonSet
conditionsArrayList of status conditions

NamespaceMapping​

The NamespaceMapping CRD defines synchronization configuration between namespaces.

apiVersion: dr-syncer.io/v1alpha1
kind: NamespaceMapping
metadata:
name: production-to-dr
spec:
sourceNamespace: production
destinationNamespace: production-dr
destinationCluster: dr-cluster
resourceTypes:
- ConfigMap
- Secret
- Deployment
- Service
- Ingress
- PersistentVolumeClaim
excludeResources:
- name: temporary-config
kind: ConfigMap
excludeLabels:
- key: dr-syncer.io/ignore
value: "true"
sync:
mode: Scheduled
schedule: "0 */6 * * *"
deploymentConfig:
scaleToZero: true
serviceConfig:
preserveClusterIP: false
ingressConfig:
preserveAnnotations: true
preserveTLS: true
preserveBackends: true
pvcConfig:
includeData: true
storageClassMapping:
standard: standard-dr
accessModeMapping:
ReadWriteOnce: ReadWriteMany
status:
phase: Running
lastSyncTime: "2025-03-08T18:00:00Z"
nextSyncTime: "2025-03-09T00:00:00Z"
syncStats:
totalSyncs: 36
successfulSyncs: 35
failedSyncs: 1
resourcesSynced: 152
resourcesFailed: 2
resourceStatus:
- kind: Deployment
synced: 10
failed: 0
- kind: ConfigMap
synced: 15
failed: 0
- kind: Secret
synced: 20
failed: 0
- kind: Service
synced: 5
failed: 0
- kind: Ingress
synced: 2
failed: 0
- kind: PersistentVolumeClaim
synced: 5
failed: 2
conditions:
- type: Syncing
status: "True"
lastTransitionTime: "2025-03-08T18:00:00Z"
reason: ScheduledSync
message: "Synchronization in progress"

NamespaceMapping Spec Fields​

FieldTypeDescriptionRequired
sourceNamespaceStringSource namespace to synchronize resources fromYes
destinationNamespaceStringDestination namespace to synchronize resources toYes
destinationClusterStringName of the RemoteCluster resource for the destination clusterYes
resourceTypesArray of StringsList of Kubernetes resource types to synchronizeYes
excludeResourcesArray of ObjectsList of specific resources to exclude from synchronizationNo
excludeResources[].nameStringName of the resource to excludeYes
excludeResources[].kindStringKind of the resource to excludeYes
excludeLabelsArray of ObjectsList of label key/value pairs to exclude resources with matching labelsNo
excludeLabels[].keyStringLabel key to matchYes
excludeLabels[].valueStringLabel value to matchNo
syncObjectSynchronization configurationNo
sync.modeStringSynchronization mode (Manual, Scheduled, Continuous)No
sync.scheduleStringCron expression for scheduled synchronizationNo
deploymentConfigObjectConfiguration for Deployment resourcesNo
deploymentConfig.scaleToZeroBooleanWhether to scale Deployments to zero replicas in the destinationNo
serviceConfigObjectConfiguration for Service resourcesNo
serviceConfig.preserveClusterIPBooleanWhether to preserve the ClusterIP in Service resourcesNo
ingressConfigObjectConfiguration for Ingress resourcesNo
ingressConfig.preserveAnnotationsBooleanWhether to preserve annotations in Ingress resourcesNo
ingressConfig.preserveTLSBooleanWhether to preserve TLS configurations in Ingress resourcesNo
ingressConfig.preserveBackendsBooleanWhether to preserve backend configurations in Ingress resourcesNo
pvcConfigObjectConfiguration for PersistentVolumeClaim resourcesNo
pvcConfig.includeDataBooleanWhether to synchronize PVC data in addition to the resourceNo
pvcConfig.storageClassMappingMapMapping of source storage classes to destination storage classesNo
pvcConfig.accessModeMappingMapMapping of source access modes to destination access modesNo

NamespaceMapping Status Fields​

FieldTypeDescription
phaseStringCurrent phase of replication (Pending, Running, Completed, Failed)
lastSyncTimeDateTimeTimestamp of the last synchronization
nextSyncTimeDateTimeEstimated timestamp of the next scheduled synchronization
syncStatsObjectSynchronization statistics
syncStats.totalSyncsIntegerTotal number of synchronization attempts
syncStats.successfulSyncsIntegerNumber of successful synchronizations
syncStats.failedSyncsIntegerNumber of failed synchronizations
syncStats.resourcesSyncedIntegerTotal number of resources successfully synchronized
syncStats.resourcesFailedIntegerTotal number of resources that failed to synchronize
resourceStatusArray of ObjectsStatus broken down by resource kind
resourceStatus[].kindStringKind of resource
resourceStatus[].syncedIntegerNumber of successfully synchronized resources of this kind
resourceStatus[].failedIntegerNumber of failed resources of this kind
conditionsArrayList of status conditions

Resource Labels​

DR-Syncer uses the following special labels to control resource behavior:

LabelDescription
dr-syncer.io/ignoreSet to "true" to exclude a resource from synchronization
dr-syncer.io/scale-overrideSet to "true" on a Deployment to maintain original replica count instead of scaling to zero

Spec Field Details​

Sync Modes​

The sync.mode field can have the following values:

  • Manual: Synchronization only happens when triggered manually
  • Scheduled: Synchronization happens according to a cron schedule
  • Continuous: Synchronization happens immediately when changes are detected

Storage Class Mapping​

The pvcConfig.storageClassMapping field allows you to map between different storage classes in source and destination clusters:

pvcConfig:
storageClassMapping:
standard: standard-dr
fast-ssd: fast-ssd-dr
local-storage: remote-storage

Access Mode Mapping​

The pvcConfig.accessModeMapping field allows you to map between different PVC access modes:

pvcConfig:
accessModeMapping:
ReadWriteOnce: ReadWriteMany
ReadOnlyMany: ReadOnlyMany

Common Usage Examples​

Basic Disaster Recovery Setup​

apiVersion: dr-syncer.io/v1alpha1
kind: RemoteCluster
metadata:
name: dr-cluster
spec:
kubeconfigSecret: dr-cluster-kubeconfig
---
apiVersion: dr-syncer.io/v1alpha1
kind: NamespaceMapping
metadata:
name: production-to-dr
spec:
sourceNamespace: production
destinationNamespace: production-dr
destinationCluster: dr-cluster
resourceTypes:
- ConfigMap
- Secret
- Deployment
- Service
sync:
mode: Scheduled
schedule: "0 */6 * * *"
deploymentConfig:
scaleToZero: true

PVC Data Replication​

apiVersion: dr-syncer.io/v1alpha1
kind: RemoteCluster
metadata:
name: dr-cluster
spec:
kubeconfigSecret: dr-cluster-kubeconfig
sshKeySecret: dr-cluster-ssh-key
---
apiVersion: dr-syncer.io/v1alpha1
kind: NamespaceMapping
metadata:
name: data-replication
spec:
sourceNamespace: database
destinationNamespace: database-dr
destinationCluster: dr-cluster
resourceTypes:
- PersistentVolumeClaim
- Deployment
- Service
pvcConfig:
includeData: true
storageClassMapping:
fast-ssd: standard-dr
accessModeMapping:
ReadWriteOnce: ReadWriteMany

Multi-Namespace Replication​

For each namespace pair you want to replicate, create a separate NamespaceMapping resource:

apiVersion: dr-syncer.io/v1alpha1
kind: NamespaceMapping
metadata:
name: production-to-dr
spec:
sourceNamespace: production
destinationNamespace: production-dr
destinationCluster: dr-cluster
resourceTypes:
- ConfigMap
- Secret
- Deployment
- Service
---
apiVersion: dr-syncer.io/v1alpha1
kind: NamespaceMapping
metadata:
name: staging-to-dr
spec:
sourceNamespace: staging
destinationNamespace: staging-dr
destinationCluster: dr-cluster
resourceTypes:
- ConfigMap
- Secret
- Deployment
- Service

Best Practices​

Deployment Configuration​

  • Use scaleToZero: true to minimize resource usage in DR environments
  • Label critical Deployments with dr-syncer.io/scale-override: "true" if they should maintain replicas in DR

Security​

  • Create a dedicated ServiceAccount in the remote cluster with the minimum required permissions
  • Regularly rotate kubeconfig and SSH key secrets
  • Use network policies to restrict connections between clusters

Monitoring​

  • Create alerts for NamespaceMapping resources with a Failed status
  • Monitor syncStats to track synchronization health over time
  • Set up dashboards to visualize replication status across multiple namespaces

Performance​

  • Consider the impact of large PVC data replication on network performance
  • For large clusters, use multiple NamespaceMapping resources with specific resource types rather than a single resource with all types
  • Schedule synchronizations during off-peak hours for production workloads