The CockroachDB operator is in .
Step 1. Prepare the migration helper
In the root of the cockroachdb/helm-charts repository, build the migration helper and add the./bin directory to your PATH:
-
Set CRDBCLUSTER to the crdbcluster custom resource name in the Public operator:
-
Set NAMESPACE to the namespace where the statefulset is installed:
-
Set CLOUD_PROVIDER to the cloud vendor where Kubernetes cluster is residing. All major cloud providers are supported (gcp, aws, azure):
-
Set REGION to the cloud provider’s identifier of this region. This region must match the “topology.kubernetes.io/region” label in the Kubernetes nodes for this cluster:
Step 2. Generate manifests with the migration helper
The CockroachDB operator uses slightly different certificates than the Public operator, and mounts them in configmaps and secrets with different names. Use the migration helper utility with themigrate-certs option to re-map and generate TLS certificates:
Step 3. Uninstall and replace the Public operator
The Public operator and the CockroachDB operator use custom resource definitions with the same names, so you must remove the Public operator before installing the CockroachDB operator. Run the following commands to uninstall the Public operator, without deleting its managed resources:-
Ensure that the operator can’t accidentally delete managed Kubernetes objects:
-
Delete the Public operator custom resource:
The
--cascade=orphanflag tells Kubernetes not to delete the dependent resources (StatefulSets, Services, PVCs, etc.) created by theCrdbClustercustom resource. This ensures that only the parent custom resource is deleted, while child resources are left intact in the cluster. This allows the CockroachDB cluster to continue running as a StatefulSet until the migration is complete. -
Delete Public operator resources and custom resource definition:
helm upgrade to install the CockroachDB operator and wait for it to become ready:
Step 4. Replace statefulset pods with operator-managed nodes
To migrate seamlessly from the Public operator to the CockroachDB operator, scale down StatefulSet-managed pods and replace them with crdbnode objects, one by one. Then we’ll create the crdbcluster object that manages the crdbnodes. Create objects withkubectl that will eventually be owned by the crdbcluster:
crdb-operator with Helm:
-
Scale the StatefulSet down by one replica. For example, for a five-node cluster, scale the StatefulSet down to four replicas:
-
Create the
crdbnoderesource that corresponds to the StatefulSet pod you just scaled down. Each manifest is labeled with the patterncrdbnode-X.yaml, whereXcorresponds to a StatefulSet pod named{STS_NAME}-X. Note the pod that was scaled down and specify its manifest in a command like the following: - Wait for the new pod to become ready. If it doesn’t, for errors.
-
Before moving on to the next replica migration, verify that there are no underreplicated ranges:
-
Set up port forwarding to access the CockroachDB node’s HTTP interface. Note that the DB Console runs on port 8080 by default:
-
Check that there are zero underreplicated ranges. The following command outputs the number of under-replicated ranges on this CockroachDB node:
-
Set up port forwarding to access the CockroachDB node’s HTTP interface. Note that the DB Console runs on port 8080 by default:
If there are issues with the migration and you need to revert back to the previous deployment, follow the rollback process.
Step 5. Update the crdbcluster manifest
The Public operator creates a pod disruption budget that conflicts with a pod disruption budget managed by the CockroachDB operator. Before applying the crdbcluster manifest, delete the existing pod disruption budget:Roll back a migration in progress
If the migration to the CockroachDB operator fails during the stage where you are applying the generatedcrdbnode manifests, follow the steps below to safely restore the original state using the previously backed-up resources and preserved volumes. This assumes the StatefulSet and PVCs are not deleted.
-
Delete the applied
crdbnoderesources and simultaneously scale the StatefulSet back up. Delete the individualcrdbnodemanifests in the reverse order of their creation (starting with the last one created, e.g.,crdbnode-1.yaml) and scale the StatefulSet back to its original replica count (e.g., 2). For example, assuming you have applied twocrdbnodeyaml files (crdbnode-2.yamlandcrdbnode-1.yaml):-
Delete a
crdbnodemanifest in reverse order, starting withcrdbnode-1.yaml. -
Scale the StatefulSet replica count up by one (to 2).
-
Verify that data has propagated by waiting for there to be zero under-replicated ranges:
-
Set up port forwarding to access the CockroachDB node’s HTTP interface, replacing
cockroachdb-Xwith the node name:The DB Console runs on port 8080 by default. -
Check the
ranges_underreplicatedmetric:This command outputs the number of under-replicated ranges on the node, which should be zero before proceeding with the next node. This may take some time depending on the deployment, but is necessary to ensure that there is no downtime in data availability.
-
Set up port forwarding to access the CockroachDB node’s HTTP interface, replacing
-
Repeat steps a through c for each node, deleting the
crdbnode-2.yaml, scaling replica count to 3, and so on. Repeat thekubectl delete -f... commandfor eachcrdbnodemanifest you applied during migration. Make sure to verify that there are no underreplicated ranges after rolling back each node.
-
Delete a
-
Delete the PriorityClass and RBAC resources created for the CockroachDB operator:
-
Uninstall the CockroachDB operator:
-
Clean up CockroachDB operator resources and custom resource definitions:
-
Restore the Public operator:
Wait for the operator pod to be “Running” as shown with the following command:
-
Restore the original
crdbclustercustom resource: -
Confirm that all CockroachDB pods are “Running” or “Ready” as shown with the following command:

