There is a command in Kubernetes that reads like housekeeping and behaves like rm -rf on your database. It is one word long, it returns success, and nothing in the output suggests you just deleted the volumes.
A warning before you read further. Against a live cluster this command deletes the database volumes, the Services and the application credentials. Do not run it to see what happens. The checks come first and the safe form is further down. Substitute <cluster> and <ns> with your own names.
kubectl delete cluster <cluster> -n <ns>
In CloudNativePG, a Cluster owns its dependents. The StatefulSet, the PVCs, the Services, the PodDisruptionBudget and the application credential Secret all carry an ownerReference back to the Cluster. Delete the owner and the garbage collector removes the children. That is correct Kubernetes behaviour. It is also a production data deletion that looks like tidying up.
I have seen this nearly happen twice. Both times the intent was a rename. Both times the plan was “delete the old one after we move over”. The second half of that sentence is where the data went.
The connection is often split across three names
Before deleting anything, list what the Cluster owns and check each one against what the running application actually reads.
The trap is that a live application rarely gets everything from one place. A connection is commonly assembled from:
- a host from one Cluster’s Service,
- credentials from another Cluster’s
-appSecret, - a CA bundle from a third source entirely.
Delete the Cluster that the credential reference names and the application stops, even though its host still resolves. The DNS name was never the thing holding the password.
A live Cluster also keeps a retired predecessor’s Services and Secrets load-bearing, through spec.externalClusters and spec.bootstrap. So the old cluster you are confident is unused may be the one supplying the credential the new one reads.
kubectl get all does not list the dependents
This is the check that makes people confident and wrong. kubectl get all omits PodDisruptionBudgets, NetworkPolicies, PodMonitors, PrometheusRules and every custom resource. A cleanup verified with get all reports “nothing left” while orphaned objects still carry the retired name.
Check each kind explicitly:
kubectl -n <ns> get pdb,networkpolicy,podmonitor,prometheusrule,svc,pvc,secret \
--no-headers | grep '<retired-name>' || echo none
Two of those orphans are not merely untidy. A PodDisruptionBudget with zero healthy pods is inert but misleading. A PDB whose minAvailable equals its replica count is worse: disruptionsAllowed goes to zero and it blocks every voluntary node drain in the namespace, weeks later, with no obvious connection to the database work that created it.
Alert rules and PodMonitors name the Cluster inside their matchers. Retire a name without rewriting them and you silence the disk, WAL, replication and archiver alerts for whatever replaced it. The new database then runs unmonitored, and everything looks calm.
If you must delete, delete the object and keep the children
The safer form is --cascade=orphan. It still deletes the Cluster object, so run it only after the checks above and after a full dump:
kubectl delete cluster <name> -n <ns> --cascade=orphan
That removes the Cluster object and leaves every dependent in place. You then retire the dependents yourself, in a reviewed order, with a soak between the steps. It is slower. It is also reversible for as long as you have not touched the PVCs.
The order that has worked for me:
- Stop the writers. Not the database, the application.
- Take a fresh logical backup of the database you are about to retire, and checksum it. Not a partial dump of the affected tables. A full dump, because that is the rollback.
- Orphan-delete the Cluster object.
- Point the application at the new host and credentials, and confirm a real read and a real write.
- Soak for a stated period. Days, not hours.
- Retire the Services, the PDB, the NetworkPolicies and the monitoring wiring.
- Only then delete the PVCs.
Step 7 is the one that cannot be undone, and it should never share a change window with steps 4 through 6.
You cannot rename a Cluster
metadata.name is immutable, and every dependent derives its name from it. So “rename” always means clone, cut over, retire. There is no annotation that renames a database.
One detail catches people during that cutover: CNPG leaves an existing unowned <name>-app Secret untouched, password included. It is not garbage-collected with the Cluster because nothing owns it. That is helpful, and it is also why a cutover that deletes Secrets “to be clean” removes a credential the application is still using.
The alert that says the database is gone
One more trap, because it turns a calm retirement into a false incident. A Prometheus rule written as something > 0 or absent(metric{...}) fires when the series disappear, not when the condition is true. During a retirement, or after an operator upgrade, the cnpg_pg_* family can vanish while replication is perfectly healthy, and every absent() rule fires at once.
The usual cause is not the scrape config. The instance manager connects as cnpg_metrics_exporter to the database named in spec.bootstrap.initdb.database. When that field is unset it falls back to the name app, and if no database called app exists, every user query in the default monitoring config fails with FATAL: database "app" does not exist. Only the built-in collector metrics survive.
Read the instance manager’s own log rather than comparing specs:
kubectl -n <ns> logs <primary-pod> -c postgres | grep -m3 'Error collecting user query'
Restoring the field fixes it. It is inert on an initialised Cluster, because initdb never runs, but the exporter reads it.
Before you type it
Print the dependents. Check which name the credential comes from. Confirm what the application reads at runtime, not what the manifest says. Take the full dump and checksum it. Then, and only then, decide whether the object is the thing to delete.
The command is honest. It deletes exactly what you asked. The problem is that almost nobody knows how much that is until it returns success.
A delete is only recoverable if the backup behind it is real, and that is a separate test: your Postgres backup is a hypothesis until you restore it.
Related Articles
Your Postgres Backup Is a Hypothesis Until You Restore It
I asked a cluster a simple question: if this database vanished in the next ten minutes, what would we restore from? The …
The Helm Value Change That Never Reached the Pod
You change an image digest in a HelmRelease. The release reconciles, reports UpgradeSucceeded, and the revision number …
The pgvector Index That Never Gets Used
Semantic search on a production table was taking five seconds. The HNSW index was there, 667 MB of it, correctly built …
Want a second read on your setup?
Paste one Dockerfile, Compose file, or CI pipeline. We read it and send back one page: the three biggest risks and the first fix. Written by an engineer, not a bot.
Get the free triage

