<p>I'm trying to add preexisting volume to one of my deployment to use persistent data to jenkins. I'm using hetzner cloud as cloud provider and also using sci drivers to point the preexisting volume. But I'm getting below error,</p>
<p><a href="https://i.stack.imgur.com/whS0b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/whS0b.png" alt="enter image description here" /></a></p>
<p>this is my volume.yml file</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-pv
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 10Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: jenkins-pvc
    namespace: development
  csi:
    driver: csi.hetzner.cloud
    fsType: ext4
    volumeHandle: &quot;111111&quot;
    readOnly: false
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: csi.hetzner.cloud/location
              operator: In
              values:
                - hel1
  persistentVolumeReclaimPolicy: Retain
  storageClassName: hcloud-volumes
  volumeMode: Filesystem

</code></pre>
<p>this is my deployment file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
  namespace: development
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins-server
  template:
    metadata:
      labels:
        app: jenkins-server
    spec:
      imagePullSecrets:
        - name: regcred
      securityContext:
        allowPrivilegeEscalation: true
        privileged: true
        readOnlyRootFilesystem: false
        runAsUser: 0
      serviceAccountName: jenkins
      containers:
        - name: jenkins
          image: jenkins/jenkins:lts-jdk11
          resources:
            limits:
              memory: &quot;2Gi&quot;
              cpu: &quot;1000m&quot;
            requests:
              memory: &quot;500Mi&quot;
              cpu: &quot;500m&quot;
          ports:
            - name: httpport
              containerPort: 8080
            - name: jnlpport
              containerPort: 50000
          livenessProbe:
            httpGet:
              path: &quot;/login&quot;
              port: 8080
            initialDelaySeconds: 90
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 5
          readinessProbe:
            httpGet:
              path: &quot;/login&quot;
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3
          volumeMounts:
            - name: jenkins-pv
              mountPath: /var/jenkins_home
      volumes:
        - name: jenkins-pv
          persistentVolumeClaim:
            claimName: jenkins-pv

</code></pre>
<p>is there any way to fix this?</p>

Hasitha Chandula
<p>I have found <a href="https://stackoverflow.com/questions/53238832/persistentvolumeclaim-jenkins-volume-claim-not-found">this similar question</a>.</p>
<p>Your error:</p>
<pre class="lang-yaml prettyprint-override"><code>Events:
  Type      Reason              Age                 From                Message
  ----      ------              ----                ----                ------
  Warning   FailedScheduling    18s (x8 over 5m26s) default-scheduler   0/4 nodes are available: 4 persistentvolumeclaim &quot;jenkins-pv&quot; not found
persistentvolumeclaim &quot;jenkins-volume-claim&quot; not found.
</code></pre>
<p>says that you're missing <code>PersistentVolumeClaim</code>  named  <code>jenkins-pv</code>.</p>
<p>Here is an example how to create one:</p>
<pre class="lang-yaml prettyprint-override"><code>kubectl -n &lt;namespace&gt; create -f - &lt;&lt;EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pv
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi
EOF
</code></pre>
<p>In case you have more that one PV available, you should use selector(s). In <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#selector" rel="nofollow noreferrer">this documentation</a> one can find how to do so. Using this the claim will bind to the desired pre-created PV with proper capacity use selector.</p>
<p>See also <a href="https://stackoverflow.com/questions/51060027/persistentvolumeclaim-not-found-in-kubernetes">this</a> and <a href="https://stackoverflow.com/questions/53874569/kubernetes-persistent-volume-mount-not-found">this</a> questions.</p>
