<p>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 -</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: postgres-pvc
spec:
 accessModes:
   - ReadWriteOnce
 resources:
   requests:
     storage: 1Gi
 storageClassName: xxxxx
</code></pre>
<p>I created the postgres pods with a <code>PGDATA</code> env set to <code>/var/lib/postgresql/pgdata</code> and mounted the PVC like so -</p>
<pre><code>oc set volume dc/postgres --add --name=postgres-pvc --type=persistentVolumeClaim \
    --claim-name=postgres-pvc --mount-path=/var/lib/postgresql/pgdata --containers=postgres
</code></pre>
<p>I originally tried to attach the PVC to <code>/var/lib/postgresql/data</code> by overwriting the original container volume but it said there was issues with something like mounting directly to that <code>data</code> folder path so that's why I used the <code>pgdata</code> one.</p>
<pre><code>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
</code></pre>
<p>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 -</p>
<pre><code>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

</code></pre>
<p>and</p>
<pre><code>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
</code></pre>
<p>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?</p>

animusdx
<p>as you can see the error</p>
<blockquote>
<p>already attached to another node xx.xx.xxx.x and there are active pods [postgres-7-6p6sz] using that</p>
</blockquote>
<p>you are utilizing a block storage as pv which has <strong>accessModes</strong> of <code>ReadWriteOnce</code> that means at any given time volume could be attached to a single kubernetes node, on that node then, a pod can mount it.
now if you want to attach to another pod, you need to remove the existing pod which will make pv to unattach from previous node, reattach to the new node.</p>
<p>for further details <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">persistent-volumes/</a></p>
