K8s/Openshift - Delete a Cassandra Datacenter in a Cluster Managed by K8ssandra Operator
Step 1: Remove the Datacenter Definition and Apply Changes
Edit the Helm values file to remove the target datacenter and reapply the configuration using Helm:
CODE
helm upgrade --install -n $NAMESPACE -f values/k8ssandra-values.yaml --timeout 60m k8ssandra-$ENV_NO helm/vid-k8ssandra-0.7.7.tgz
Step 2: Decommission Cassandra Nodes
For each node in the datacenter you are removing, execute the following command to decommission the node:
CODE
oc -n $NAMESPACE exec <POD_NAME> -- nodetool --ssl decommission --force
Step 3: Allow CassandraDatacenter Resource Deletion
Remove the finalizers from the CassandraDatacenter resource to permit deletion:
CODE
oc -n $NAMESPACE get cassandradatacenter dc2 -oyaml | yq -y '.metadata.finalizers=[]' | oc -n $NAMESPACE apply -f -
Step 4: Delete Persistent Volumes
Finally, delete the associated persistent volumes for the datacenter:
CODE
oc -n $NAMESPACE delete pvc -l cassandra.datastax.com/datacenter=dc2