Resize a Persistent Volume Claim (PVC) for Postgres that supports volume
expansion.
About this task
You can expand a PVC if your storage provisioner
supports volume expansion.
Procedure
-
Determine the primary Postgres pod.
oc get pods --selector role=master | grep -v bootstrapselector=role=master
-
Gracefully shutdown Postgres pods.
-
Exec into the Postgres primary pod.
oc exec -it <postgres-pod> -- bash
-
Pause Patroni process. Note: you can skip this step if using the one replica profile.
-
Stop the Postgres process gracefully.
pg_ctl stop -D /pgdata/<cluster-name>
For example:
-
Determine the PVC linked to the primary Postgres pod, and obtain the
claimName
of the PVC.
oc get pod <postgres-pod> -o json | jq '.spec.volumes[] | select ( has ("persistentVolumeClaim"))'
-
Scale down the Postgres deployment.
oc get deploy | grep postgres | grep -v bouncer | grep -v bootstrap | grep -v backrest | grep -v operator
If you are using n3
profile then you find 3 deployments. Scale them down:
oc scale deploy <deployment-name> --replicas=0
-
Edit the PVC you want to increase.
-
Update
spec.resources.requests.storage
field value with new size. For
example:
spec:
resources:
requests:
storage: 20Gi
-
Scale up the Postgres deployment.
oc get deploy | grep postgres | grep -v bouncer | grep -v bootstrap | grep -v backrest | grep -v operator
If you are using the n3
profile then you find 3 deployments. Scale them up:
oc scale deploy <deployment-name> --replicas=1
-
If you are using the
n3
profile, resume the Patroni process. If using the
n1
profile, skip this step.
-
Identify the Postgres pods.
oc get pods --selector role
-
Exec into any Postgres pod.
oc exec -it <postgres-pod> -- bash
-
Resume Patroni.