I have a postgres pod deployed on OpenShift and a PVC that I think that I correctly attached but I could be wrong. This is my PVC and it is correctly Bound -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: xxxxx
I created the postgres pods with a PGDATA
env set to /var/lib/postgresql/pgdata
and mounted the PVC like so -
oc set volume dc/postgres --add --name=postgres-pvc --type=persistentVolumeClaim \
--claim-name=postgres-pvc --mount-path=/var/lib/postgresql/pgdata --containers=postgres
I originally tried to attach the PVC to /var/lib/postgresql/data
by overwriting the original container volume but it said there was issues with something like mounting directly to that data
folder path so that's why I used the pgdata
one.
oc set volume dc/postgres --add --overwrite --name=postgres-volume-1 --type=persistentVolumeClaim \
--claim-name=postgres-pvc --mount-path=/var/lib/postgresql/data --containers=postgres
The error that I get now is when I try to scale up the pod/add a replica via the DC, it gives the following errors -
Unable to attach or mount volumes: unmounted volumes=[postgres-pvc], unattached volumes=[postgres-volume-1 postgres-pvc postgres-token-h7jvr]: timed out waiting for the condition
and
Error while attaching the device pv pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b cannot be attached to the node xx.xx.xxx.xx. Error: PV pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b is already attached to another node xx.xx.xxx.x and there are active pods [postgres-7-6p6sz] using that
Is it because I did an incorrect mount of my PVC? Or do I need to create a new PVC and then manually update the new pod to that newly created PVC?