Repository navigation
Description
Is there an existing issue already for this feature request/idea?
- I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.
What problem is this feature going to solve? Why should it be added?
The primary cluster instance can be destroyed without a warning.
This can cause a downtime or accidental deleting of the primary instance.
Describe the solution you'd like
cnpg destroy -n cnpg-system cnpgcluster cnpgcluster-1
cnpgcluster-1 is currently your primary instance of cluster cnpgcluster do you really want to destroy the primary instance (yes/no):
yes
Instance cnpgcluster-1 of cluster cnpgcluster is destroyed
no
bash prompt
Describe alternatives you've considered
I don't this an alternative exists, except may be a wrapper.
Additional context
How it looks like:
Cluster status cnpgcluster-1 is the primary/
kubectl cnpg status -n cnpg-system cnpgcluster
Cluster Summary
Name cnpg-system/cnpgcluster
System ID: 7572559971907399698
PostgreSQL Image: ghcr.io/cloudnative-pg/postgresql:16.10-system-trixie
Primary instance: cnpgcluster-1
Primary promotion time: 2025-11-14 12:40:28 +0000 UTC (16m28s)
Status: Cluster in healthy state
Instances: 3
Ready instances: 3
Size: 127M
Current Write LSN: 0/7000000 (Timeline: 1 - WAL File: 000000010000000000000006)
Continuous Backup status (Barman Cloud Plugin)
ObjectStore / Server name: minio-store/cnpgcluster
First Point of Recoverability: -
Last Successful Backup: -
Last Failed Backup: -
Working WAL archiving: OK
WALs waiting to be archived: 0
Last Archived WAL: 000000010000000000000006 @ 2025-11-14T12:46:43.924158Z
Last Failed WAL: -
Streaming Replication status
Replication Slots Enabled
Name Sent LSN Write LSN Flush LSN Replay LSN Write Lag Flush Lag Replay Lag State Sync State Sync Priority Replication Slot
cnpgcluster-2 0/7000000 0/7000000 0/7000000 0/7000000 00:00:00 00:00:00 00:00:00 streaming quorum 1 active
cnpgcluster-3 0/7000000 0/7000000 0/7000000 0/7000000 00:00:00 00:00:00 00:00:00 streaming quorum 1 active
Instances status
Name Current LSN Replication role Status QoS Manager Version Node
cnpgcluster-1 0/7000000 Primary OK Burstable 1.27.1 debian-rke2-cp-2
cnpgcluster-2 0/7000000 Standby (sync) OK Burstable 1.27.1 debian-rke2-cp-3
cnpgcluster-3 0/7000000 Standby (sync) OK Burstable 1.27.1 debian-rke2-cp-1
Plugins status
Name Version Status Reported Operator Capabilities
barman-cloud.cloudnative-pg.io 0.9.0 N/A Reconciler Hooks, Lifecycle Service
Destroy the primary instance i.e. cnpgcluster-1
kubectl cnpg destroy -n cnpg-system cnpgcluster cnpgcluster-1
Instance cnpgcluster-1 of cluster cnpgcluster is destroyed
The new status
kubectl cnpg status -n cnpg-system cnpgcluster
Cluster Summary
Switchover in progress
Name cnpg-system/cnpgcluster
PostgreSQL Image: ghcr.io/cloudnative-pg/postgresql:16.10-system-trixie
Primary instance: cnpgcluster-1 (switching to cnpgcluster-2)
Primary promotion time: 2025-11-14 12:40:28 +0000 UTC (17m25s)
Status: Failing over Failing over from cnpgcluster-1 to cnpgcluster-2
Instances: 3
Ready instances: 2
Size: container not found
Continuous Backup status (Barman Cloud Plugin)
ObjectStore / Server name: minio-store/cnpgcluster
First Point of Recoverability: -
Last Successful Backup: -
Last Failed Backup: -
No Primary instance found
Physical backups
Primary instance not found
Streaming Replication status
Primary instance not found
Instances status
Name Current LSN Replication role Status QoS Manager Version Node
cnpgcluster-2 0/80000A0 Standby (file based) OK Burstable 1.27.1 debian-rke2-cp-3
cnpgcluster-3 0/80000A0 Standby (file based) OK Burstable 1.27.1 debian-rke2-cp-1
Plugins status
Name Version Status Reported Operator Capabilities
barman-cloud.cloudnative-pg.io 0.9.0 N/A Reconciler Hooks, Lifecycle Service
After a while:
kubectl cnpg status -n cnpg-system cnpgcluster
Cluster Summary
Name cnpg-system/cnpgcluster
System ID: 7572559971907399698
PostgreSQL Image: ghcr.io/cloudnative-pg/postgresql:16.10-system-trixie
Primary instance: cnpgcluster-2
Primary promotion time: 2025-11-14 12:57:55 +0000 UTC (6m42s)
Status: Cluster in healthy state
Instances: 3
Ready instances: 3
Size: 176M
Current Write LSN: 0/B000000 (Timeline: 2 - WAL File: 00000002000000000000000A)
Continuous Backup status (Barman Cloud Plugin)
ObjectStore / Server name: minio-store/cnpgcluster
First Point of Recoverability: -
Last Successful Backup: -
Last Failed Backup: -
Working WAL archiving: OK
WALs waiting to be archived: 0
Last Archived WAL: 00000002000000000000000A @ 2025-11-14T13:03:03.689099Z
Last Failed WAL: 00000002.history @ 2025-11-14T12:57:54.916367Z
Streaming Replication status
Replication Slots Enabled
Name Sent LSN Write LSN Flush LSN Replay LSN Write Lag Flush Lag Replay Lag State Sync State Sync Priority Replication Slot
cnpgcluster-3 0/B000000 0/B000000 0/B000000 0/B000000 00:00:00 00:00:00 00:00:00 streaming quorum 1 active
cnpgcluster-4 0/B000000 0/B000000 0/B000000 0/B000000 00:00:00 00:00:00 00:00:00 streaming quorum 1 active
Instances status
Name Current LSN Replication role Status QoS Manager Version Node
cnpgcluster-2 0/B000000 Primary OK Burstable 1.27.1 debian-rke2-cp-3
cnpgcluster-3 0/B000000 Standby (sync) OK Burstable 1.27.1 debian-rke2-cp-1
cnpgcluster-4 0/B000000 Standby (sync) OK Burstable 1.27.1 debian-rke2-cp-2
Plugins status
Name Version Status Reported Operator Capabilities
barman-cloud.cloudnative-pg.io 0.9.0 N/A Reconciler Hooks, Lifecycle Service
This all works fine. But a mentioned maybe accidental primary deletion and/or downtime
Backport?
Yes
Are you willing to actively contribute to this feature?
No
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
github-actions commentedon Jan 18, 2026
This issue is stale because it has been open for 60 days with no activity.
cd-jbo commentedon Jan 19, 2026
Do / can I do something to move this ticket forward?
dosubot commentedon Apr 21, 2026
Hi, @cd-jbo. I'm Dosu, and I'm helping the cloudnative-pg team manage their backlog and am marking this issue as stale.
Issue Summary:
Next Steps:
Thank you for your understanding and contribution!
sebastiaankok commentedon May 6, 2026
Was looking into this after dealing with a CNPG cluster with 2 broken replica pods. A simple typo could have caused unnecessary downtime. We’ve created a Kyverno policy to prevent PVC deletion when the label role=primary is present.
Having a confirmation mechanism when deleting the primary would make destroy much safer.
I’d like to work on this.
github-actions commentedon Sep 8, 2026
This issue is stale because it has been open for 60 days with no activity.
github-actions commentedon Sep 30, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.