New to KubeDB? Please start here.

Branch Neo4j into Another Namespace

Same-cluster branching creates an independent Neo4j deployment from a point-in-time snapshot within the same Kubernetes cluster. Place the branch in another namespace to prepare development, testing, or data analysis environments using existing data.

The branch accepts independent reads and writes without changing the source. Source changes are not continuously replicated; scheduled refreshes can replace branch data with fresh source snapshots.

Before You Begin

  • Read the branching overview.
  • Complete Courier setup, including KubeDB and the Branch CRD. Use branching-capable Courier, provisioner, and database images.
  • Ensure Neo4jVersion 2025.12.1 is available in your installed catalog.
  • Use Ceph RBD storage with copy-on-write cloning, compatible VolumeSnapshot and VolumeGroupSnapshot classes, and the corresponding CSI APIs, controllers, and driver support.
  • Review the snapshot requirements. Your account must be able to create databases and Branches, read auth Secrets, inspect snapshots and Jobs, and open pod shells.
  • Allow capacity for three source and three target database pods, each requesting 2Gi of memory, plus operators and action Jobs.

The source uses demo; the target uses dev. Replace ceph-rbd consistently if your Ceph StorageClass has another name. Reserve the tutorial names and create namespaces if they do not already exist:

kubectl create namespace demo
kubectl create namespace dev

Deploy the source database

Save the following as neo4j-source.yaml. It creates a three-server cluster:

apiVersion: kubedb.com/v1alpha2
kind: Neo4j
metadata:
  name: neo4j-source
  namespace: demo
spec:
  version: 2025.12.1
  replicas: 3
  podTemplate:
    spec:
      containers:
      - name: neo4j
        resources:
          requests:
            cpu: 500m
            memory: 2Gi
          limits:
            memory: 2Gi
  storageType: Durable
  storage:
    storageClassName: ceph-rbd
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 4Gi
  deletionPolicy: WipeOut
kubectl -n demo apply -f neo4j-source.yaml
kubectl -n demo wait neo4j/neo4j-source --for=jsonpath='{.status.phase}'=Ready --timeout=30m

Use the Enterprise server catalog entry for this cluster. The client examples select database neo4j and use routing so writes reach its leader.

Seed and inspect the source data

Discover the auth Secret referenced by neo4j-source:

kubectl -n demo get neo4j neo4j-source -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-source-auth

Use the returned name below if it differs. Read its password:

kubectl -n demo get secret neo4j-source-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n demo exec -it neo4j-source-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-source.demo.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

Create five customers. Expected results below omit connection banners and are formatted for readability.

CREATE (c1:Customer {id: 1, full_name: "Customer 1", email: "[email protected]"}),
       (c2:Customer {id: 2, full_name: "Customer 2", email: "[email protected]"}),
       (c3:Customer {id: 3, full_name: "Customer 3", email: "[email protected]"}),
       (c4:Customer {id: 4, full_name: "Customer 4", email: "[email protected]"}),
       (c5:Customer {id: 5, full_name: "Customer 5", email: "[email protected]"});
CALL db.checkpoint();

db.checkpoint() is provided by the Enterprise server used here. Committed transaction logs still support recovery when the cloned database starts.

MATCH (c:Customer) RETURN c.id AS id, c.full_name AS full_name, c.email AS email ORDER BY id;
id, full_name, email
1, "Customer 1", "[email protected]"
2, "Customer 2", "[email protected]"
3, "Customer 3", "[email protected]"
4, "Customer 4", "[email protected]"
5, "Customer 5", "[email protected]"

Run :exit to leave cypher-shell, then exit to leave the pod shell.

Create the Branch

Save the following as neo4j-dev.yaml:

apiVersion: courier.kubedb.com/v1alpha1
kind: Branch
metadata:
  name: neo4j-dev
  namespace: demo
spec:
  source:
    databaseRef:
      apiGroup: kubedb.com
      kind: Neo4j
      name: neo4j-source
    namespace: demo
  target:
    namespace: dev
    name: neo4j-dev
    storageClassName: ceph-rbd
    resources:
      requests:
        cpu: 500m
        memory: 2Gi
      limits:
        memory: 2Gi
  deletionPolicy: Delete
kubectl -n demo apply -f neo4j-dev.yaml
kubectl -n demo wait branch/neo4j-dev --for=condition=Ready --timeout=60m
kubectl -n demo get branch neo4j-dev

Courier creates neo4j/neo4j-dev and its cloned PVCs in dev; KubeDB provisions the target database.

Verify the copied data

Discover the auth Secret referenced by neo4j-dev:

kubectl -n dev get neo4j neo4j-dev -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-dev-auth

Use the returned name below if it differs. Read its password:

kubectl -n dev get secret neo4j-dev-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n dev exec -it neo4j-dev-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-dev.dev.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

MATCH (c:Customer) RETURN c.id AS id, c.full_name AS full_name, c.email AS email ORDER BY id;
id, full_name, email
1, "Customer 1", "[email protected]"
2, "Customer 2", "[email protected]"
3, "Customer 3", "[email protected]"
4, "Customer 4", "[email protected]"
5, "Customer 5", "[email protected]"

Run :exit to leave cypher-shell, then exit to leave the pod shell.

Inspect target resources

kubectl -n dev get pods,pvc -l app.kubernetes.io/instance=neo4j-dev

Discover the auth Secret referenced by neo4j-dev:

kubectl -n dev get neo4j neo4j-dev -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-dev-auth

Use the returned name below if it differs. Read its password:

kubectl -n dev get secret neo4j-dev-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n dev exec -it neo4j-dev-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-dev.dev.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

SHOW SERVERS YIELD address, state, health RETURN address, state, health;
SHOW DATABASES YIELD name, address, writer, currentStatus RETURN name, address, writer, currentStatus;

Expect three branch server addresses, available servers, and online databases with a writer for neo4j.

Run :exit to leave cypher-shell, then exit to leave the pod shell.

Verify independent writes

Change the branch

Discover the auth Secret referenced by neo4j-dev:

kubectl -n dev get neo4j neo4j-dev -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-dev-auth

Use the returned name below if it differs. Read its password:

kubectl -n dev get secret neo4j-dev-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n dev exec -it neo4j-dev-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-dev.dev.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

MATCH (c:Customer {id: 5}) SET c.full_name = "Branch-only Customer 5";
CALL db.checkpoint();
MATCH (c:Customer) RETURN c.id AS id, c.full_name AS full_name, c.email AS email ORDER BY id;
id, full_name, email
1, "Customer 1", "[email protected]"
2, "Customer 2", "[email protected]"
3, "Customer 3", "[email protected]"
4, "Customer 4", "[email protected]"
5, "Branch-only Customer 5", "[email protected]"

Run :exit to leave cypher-shell, then exit to leave the pod shell.

Change and inspect the source

Discover the auth Secret referenced by neo4j-source:

kubectl -n demo get neo4j neo4j-source -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-source-auth

Use the returned name below if it differs. Read its password:

kubectl -n demo get secret neo4j-source-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n demo exec -it neo4j-source-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-source.demo.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

MATCH (c:Customer {id: 1}) SET c.full_name = "Updated Customer 1";
CALL db.checkpoint();
MATCH (c:Customer) RETURN c.id AS id, c.full_name AS full_name, c.email AS email ORDER BY id;
id, full_name, email
1, "Updated Customer 1", "[email protected]"
2, "Customer 2", "[email protected]"
3, "Customer 3", "[email protected]"
4, "Customer 4", "[email protected]"
5, "Customer 5", "[email protected]"

Run :exit to leave cypher-shell, then exit to leave the pod shell.

The source retains the original customer 5; the branch edit did not reach it.

Check the branch again

Discover the auth Secret referenced by neo4j-dev:

kubectl -n dev get neo4j neo4j-dev -o jsonpath='{.spec.authSecret.name}{"\n"}'
neo4j-dev-auth

Use the returned name below if it differs. Read its password:

kubectl -n dev get secret neo4j-dev-auth -o jsonpath='{.data.password}' | base64 -d

Enter this password when the client prompts.

From your terminal, open a pod shell:

kubectl -n dev exec -it neo4j-dev-0 -c neo4j -- bash

Inside the pod, start the client through the writable database Service:

cypher-shell -a neo4j://neo4j-dev.dev.svc:7687 -u neo4j -d neo4j --format plain

Enter Cypher at the client prompt. neo4j:// discovers the cluster’s writer; a direct bolt:// connection to an arbitrary member can reject writes.

MATCH (c:Customer) RETURN c.id AS id, c.full_name AS full_name, c.email AS email ORDER BY id;
id, full_name, email
1, "Customer 1", "[email protected]"
2, "Customer 2", "[email protected]"
3, "Customer 3", "[email protected]"
4, "Customer 4", "[email protected]"
5, "Branch-only Customer 5", "[email protected]"

Run :exit to leave cypher-shell, then exit to leave the pod shell.

The branch retains its own customer 5 and the original customer 1. The source update did not reach it.

Cleanup

Delete the Branch on the source cluster first. Let Courier remove its target and snapshots before deleting the source:

kubectl -n demo delete branch neo4j-dev --wait=true --timeout=30m
kubectl -n demo delete neo4j neo4j-source --wait=true --timeout=30m

Keep Courier, CSI, the shared backend, and OCM when used available until cleanup completes. These commands leave the namespaces in place.

Next Steps