PostgreSQL-HA on Kubernetes recover from Volume Snapshot?

9/10/2021

I have a Kubernetes Volume Snapshot created for pgsql-ha persistent volume backup.

Now that I'm able to recover the PVC by specifying the dataSource as the volume snapshot, and trying to create a new pgsql-ha cluster using HELM chart, then attach this PCV to recover the data. Following is the example installation command:

helm install db-ha bitnami/postgresql-ha\
    --set postgresql.password=$PWD \
    --set persistence.existingClaim="pvc-restore-from-snapshot"

Then the pgpol and both postgresql Pods shows CrashLoopBackOff forever.

$ kubectl get pods --watch
NAME                           READY   STATUS             RESTARTS   AGE
db-ha-pgpool-gradfergr43sfxv   0/1     Running            0          8s
db-ha-postgresql-0             0/1     Init:0/1           0          8s
db-ha-postgresql-1             0/1     Init:0/1           0          8s
db-ha-postgresql-1             0/1     PodInitializing    0          23s
db-ha-postgresql-0             0/1     PodInitializing    0          23s
db-ha-postgresql-1             0/1     Error              0          24s
db-ha-postgresql-0             0/1     Error              0          24s
db-ha-postgresql-1             0/1     Error              1          25s
db-ha-postgresql-0             0/1     Error              1          25s
db-ha-postgresql-1             0/1     CrashLoopBackOff   1          26s
db-ha-postgresql-0             0/1     CrashLoopBackOff   1          27s

From what I have read so far in this issue, persistence.existingClaim is only supported when replica was set to 1, which means it can only be restored on a non-ha cluster, and pgsql-ha is currently unable to replicate the manually specified PVC.

So I'm wondering the following:

  • If that is the whole story, and there is nothing that I'm missing
  • If it's possible to modify the storageClass or even the provisioner (ebs-csi), so that the existing PVC can be used
  • If other workaround exist for this workflow

Many thanks!

-- FrozenBeef
amazon-eks
kubernetes
kubernetes-helm
persistent-volume-claims
postgresql

0 Answers