<p>I have created a deployment in the xyz-namespace namespace, it has PVC. I can create the deployment and able to access it. It is working properly but while scale the deployment from the Kubernetes console then the pod is pending state only.</p>
<pre><code>persistent_claim:
  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: jenkins
  spec:
    accessModes:
    - ReadWriteOnce
    storageClassName: standard
    resources:
      requests:
        storage: 5Gi
namespace: xyz-namespace
</code></pre>
<p>and deployment object is like below.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: db-service
  labels:
    k8s-app: db-service
    Name:db-service
    ServiceName: db-service
spec:
  selector:
    matchLabels:
      tier: data
      Name: db-service
      ServiceName: db-service
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: jenkins
        tier: data
        Name: db-service
        ServiceName: db-service
    spec:
      hostname: jenkins
      initContainers:
      - command:
        - &quot;/bin/sh&quot;
        - &quot;-c&quot;
        - chown -R 1000:1000 /var/jenkins_home
        image: busybox
        imagePullPolicy: Always
        name: jenkins-init
        volumeMounts:
        - name: jenkinsvol
          mountPath: &quot;/var/jenkins_home&quot;
      containers:
      - image: jenkins/jenkins:lts
        name: jenkins
        ports:
        - containerPort: 8080
          name: jenkins1
        - containerPort: 8080
          name: jenkins2
        volumeMounts:
        - name: jenkinsvol
          mountPath: &quot;/var/jenkins_home&quot;
      volumes:
      - name: jenkinsvol
        persistentVolumeClaim:
          claimName: jenkins
      nodeSelector:
        nodegroup: xyz-testing
namespace: xyz-namespace
replicas: 1
</code></pre>
<p>Deployment is created fine and working as well but
When I am trying to <strong>Scale the deployment</strong> from console then the pod is getting stuck and it's pending state only.</p>
<p>If I removed the persistent volume and then scaled it then it is working fine, but with persistent volume, it is not working.</p>

<p>When using standard storage class I assume you are using the default <code>GCEPersisentDisk</code> Volume PlugIn. In this case you cannot set them at all as they are already set by the storage provider (GCP in your case, as you are using GCE perisistent disks), these disks only support <code>ReadWriteOnce</code>(RWO) and <code>ReadOnlyMany</code> (ROX) access modes. If you try to create a <code>ReadWriteMany</code>(RWX) PV that will never come in a success state (your case when set the PVC with accessModes: ReadWriteMany).</p>
<p>Also if any pod tries to attach a ReadWriteOnce volume on some other node, you’ll get following error:</p>
<pre><code>FailedMount Failed to attach volume &quot;pv0001&quot; on node &quot;xyz&quot; with: googleapi: Error 400: The disk resource 'abc' is already being used by 'xyz'
</code></pre>
<p>References from above on this <a href="https://medium.com/@Sushil_Kumar/readwritemany-persistent-volumes-in-google-kubernetes-engine-a0b93e203180" rel="nofollow noreferrer">article</a></p>
<p>As mentioned <a href="https://medium.com/@Sushil_Kumar/readwritemany-persistent-volumes-in-google-kubernetes-engine-a0b93e203180" rel="nofollow noreferrer">here</a> and <a href="https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/544" rel="nofollow noreferrer">here</a>, NFS is the easiest way to get ReadWriteMany as all nodes need to be able to ReadWriteMany to the storage device you are using for your pods.</p>
<p>Then I would suggest you to use an NFS storage option. In case you want to test it, here is a good <a href="https://cloud.google.com/filestore/docs/accessing-fileshares" rel="nofollow noreferrer">guide</a> by Google using its Filestore solution which are fully managed NFS file servers.</p>
