Skip to content

Tips

Minimal cluster

This is the minimal cluster spec

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: sinbootstrap
spec:
  storage:
    storageClass: standard
    size: 1Gi

Recreate all the cluster nodes

  • Destroy 2 replicas
kubectl cnpg destroy MYCLUSTER ONE-REPLICA
kubectl cnpg destroy MYCLUSTER ANOTHER-REPLICA

Once they are ok, promote a replica to be primary

kubectl cnpg promote MYCLUSTER ONE-REPLICA

Once is prometed, destroy the older primary

kubectl cnpg destroy MYCLUSTER OLD-PRIMARY

Info about primary replicas

Show the nodes where the replicas are located

kubectl get pod -A -l cnpg.io/instanceRole=primary -o custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace,NODE:.spec.nodeName

get an sql session

kubectl cnpg psql mycluster
SELECT timeline_id FROM pg_control_checkpoint();