Operations Runbook
Practical reference for day-2 operations of an Alauda CloudNativePG cluster. Each section is self-contained — jump to the operation you need.
Address CNPG clusters as cluster.postgresql.cnpg.io in kubectl
commands — on ACP clusters the bare cluster shortname resolves to
Cluster API's resource instead. Several procedures below use the
cnpg kubectl plugin (kubectl cnpg ...); install it from the
upstream CloudNativePG release artifacts.
TOC
Cluster lifecycleCreate a clusterScale instancesSwitchover (planned, no data loss)Delete a clusterBackup and restoreConfigure backup storageOn-demand backupScheduled backupRestore from backupVerify a backup existsFailover scenariosAutomatic failover on primary pod lossManual failover (replace a misbehaving primary)Disaster recovery (whole cluster lost)Drain and node maintenanceDrain a worker nodeCordon during upgradeOperator and PostgreSQL upgradesOperator (OLM bundle) upgradePostgreSQL major version upgrade (e.g. 17 → 18)Minor / patch upgradeMonitoringLog accessTroubleshooting matrixWhere to report issuesCluster lifecycle
Create a cluster
Wait for phase: Cluster in healthy state. A 3-instance cluster
typically reaches healthy in two to five minutes (first-use image pull
dominates).
Scale instances
Increase or decrease replicas by editing spec.instances:
Scale-up adds new standby pods (one at a time); scale-down removes the highest-numbered replica. The primary is never deleted by scale-down — to remove the primary's pod, do a switchover first.
Switchover (planned, no data loss)
Use the cnpg kubectl plugin to promote a specific replica:
The current primary completes in-flight transactions, the target
replica promotes, and the old primary rejoins as a standby. Total
write-downtime is typically 5–15 seconds. (spec.switchoverDelay
controls how long the operator waits for the old primary to shut down
cleanly.)
Delete a cluster
Deleting a Cluster deletes its PVCs — and therefore its data. The
instance PVCs are owned by the Cluster and are garbage-collected with
it. Before deleting, take a final backup (and verify it!), or hibernate
the cluster instead (cnpg.io/hibernation: "on" annotation) if you
want to stop compute but keep the volumes.
Backup and restore
Configure backup storage
CNPG uses the Barman Cloud plugin for S3-compatible backups. See Quick Start: Step 3 for the create flow — including the rolling restart the plugin attach triggers (wait for healthy before the first backup).
On-demand backup
Watch progress: kubectl get backup -n <ns>. The phase transitions
running → completed (or failed). Small clusters back up in 10–60
seconds.
Scheduled backup
To run the FIRST backup immediately at creation time, set
immediate: true. Note: patching immediate: true onto an existing
ScheduledBackup does NOT retroactively fire — it is only honored at
creation.
Restore from backup
Create a new Cluster with bootstrap.recovery pointing at the source
cluster's ObjectStore. Use externalClusters to declare the source:
A full-recovery job runs first (~30–60 seconds on small clusters), then the new primary comes up. PITR requires the recovery target time to fall within the source's WAL archive range.
Verify a backup exists
Failover scenarios
Automatic failover on primary pod loss
If the primary pod is deleted, killed, or its node fails, the operator promotes the most-advanced standby automatically. No manual action needed.
kubectl cnpg status <cluster> -n <ns> shows the replication topology
and which pod is currently primary.
Manual failover (replace a misbehaving primary)
For planned replacement, use the switchover procedure above
(kubectl cnpg promote). Avoid kubectl delete pod on the primary —
switchover is cleaner.
Disaster recovery (whole cluster lost)
Restore from the most recent backup into a new namespace or new cluster name following the Restore from backup procedure.
Drain and node maintenance
Drain a worker node
CNPG creates PodDisruptionBudgets per cluster, so kubectl drain
behaves safely:
Behavior depends on which pod is on the drained node:
For synchronous-replication clusters, drain ONE node at a time and wait
for kubectl cnpg status to show all replicas streaming again before
draining the next.
Cordon during upgrade
When upgrading worker nodes, cordon first, then drain. The operator
reschedules pods to other workers automatically. If pods can't be
rescheduled (insufficient capacity), add nodes or temporarily reduce
spec.instances before draining.
Operator and PostgreSQL upgrades
Operator (OLM bundle) upgrade
OLM picks up new versions from the catalog automatically when
installPlanApproval: Automatic. The CSV transitions from old to new
with the operator pod restarting once. PostgreSQL pods are NOT
recreated during operator upgrades — they continue running unchanged.
If you have installPlanApproval: Manual, an InstallPlan stays at
phase: RequiresApproval until you patch it:
See Upgrade for release-to-release specifics.
PostgreSQL major version upgrade (e.g. 17 → 18)
CNPG supports declarative major upgrades: point the cluster at an
operand image of the next major (spec.imageName, or
spec.imageCatalogRef.major if you manage a catalog). The operator
performs an offline upgrade: instances shut down, pg_upgrade runs
in a dedicated job, then instances return on the new major (replicas
are re-created from the upgraded primary).
Take a backup before triggering, verify extension compatibility
with the new major first, and expect write-downtime for the duration of
the pg_upgrade job (size-dependent).
Minor / patch upgrade
Updating the PostgreSQL minor version (e.g. 18.3 → 18.4) is a rolling update: replicas restart on the new image one at a time, then a switchover, then the old primary updates. Typical write-downtime: 5–15 seconds (the switchover).
Monitoring
Every instance exposes metrics on port 9187 via the built-in
exporter; the default query pack (cnpg-default-monitoring ConfigMap
in cnpg-system) is installed and wired automatically by the operator
at startup — nothing to configure on the Cluster.
To scrape the metrics on ACP you need a PodMonitor carrying the
prometheus: kube-prometheus label, and for visualization import the
two curated dashboards — both covered step-by-step in
Grafana dashboards.
Log access
Logs are JSON-formatted; pipe through jq for readability.
Troubleshooting matrix
For configuration-level issues see the troubleshooting quick reference.
Where to report issues
- Product issues (operator, images, backup plugin): through your Alauda support channel.
- Documentation issues: GitHub
alauda/cnpg-docs.
Reference Architecture for the deeper model behind these operations.