<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>Your PersistentVolumeClaim is set to:</p>
<pre><code>accessModes:
- ReadWriteOnce
</code></pre>
<p>But it should be set to:</p>
<pre><code>accessModes:
- ReadWriteMany
</code></pre>
<p>The ReadWriteOnce access mode means, that</p>
<blockquote>
<p>the volume can be mounted as read-write by a single node [1].</p>
</blockquote>
<p>When you scale your deployment it's most likely scaled to different nodes, therefore you need ReadWriteMany.</p>
<p>[1] <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a></p>
