New to KubeDB? Please start here.

MongoDB Branching Overview

KubeDB Courier creates independent MongoDB deployments from CSI storage snapshots on copy-on-write storage such as Ceph RBD. Use a branch to develop against existing data, test changes, or prepare an isolated environment. Writes on either side do not propagate to the other; optional refresh replaces branch data with a fresh source snapshot.

The tutorials use a three-member replica set. Courier snapshots the data-bearing replica-set members, and KubeDB recovers them with the branch’s member addresses and a separate keyfile.

Start with the common branching architecture and Courier setup.

The Branch resource

A Branch is a namespaced courier.kubedb.com/v1alpha1 resource created on the source cluster. This example selects a source in demo and a target in dev:

apiVersion: courier.kubedb.com/v1alpha1
kind: Branch
metadata:
  name: mongodb-dev
  namespace: demo
spec:
  source:
    databaseRef:
      apiGroup: kubedb.com
      kind: MongoDB
      name: mongodb-source
    namespace: demo
  target:
    namespace: dev
    name: mongodb-dev
    storageClassName: ceph-rbd
    resources:
      requests:
        cpu: 500m
        memory: 1Gi
      limits:
        memory: 1Gi
  deletionPolicy: Delete

Source and target

source.databaseRef selects the KubeDB resource, while source.namespace locates it. target.name and target.namespace identify the new deployment. Omit target.clusterName for the same cluster; for OCM, set it to the target ManagedCluster name.

target.storageClassName selects storage backed by the same Ceph system as the snapshots. target.resources sets database container resources for this example. The source requires durable storage.

Optional behavior

Status and readiness

The Branch progresses through snapshot creation, target provisioning, optional credential reset and actions, then Ready. A refresh temporarily leaves readiness while target storage is replaced. Inspect the original Branch for completion:

kubectl -n demo get branch mongodb-dev
kubectl -n demo get branch mongodb-dev -o yaml

status.resources references the cloned PVCs, auth Secret, and action Job when present. status.snapshot records the strategy and generation. Readiness includes configured preparation; the target database becoming ready alone does not establish that its post-actions have finished.