<p>I am trying to make a local volume to save logs from a pod to their node in an isolated environment. So, I am trying to make a PV and a PVC on the specific node that has the <code>tier=production</code> tag. I have labeled the node with the tag:</p>
<pre><code>$ k get nodes --show-labels
NAME             STATUS   ROLES           AGE   VERSION   LABELS
xxx              Ready    Worker          12d   v1.25.2   &lt;lots of lables&gt;,tier=production
</code></pre>
<p>Following the <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#local" rel="nofollow noreferrer">Local Volume</a> and the <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#local" rel="nofollow noreferrer">Storage Class</a> docs, I have created the following yaml to deploy the volume, claim, and my pod:</p>
<pre class="lang-yaml prettyprint-override"><code>---
# A storage class to define local storage
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

---
# Volume using a local filesystem
apiVersion: v1
kind: PersistentVolume
metadata:
  name: volume-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /tmp/nginx/
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: tier
          operator: In
          values:
          - production

---
# Request a claim on the file system volume
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: volume-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-storage
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi
  selector:
    matchExpressions:
    - key: tier
      operator: In
      values:
      - production

---
# Make a pod that uses the volume
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        preference:
          matchExpressions:
          - key: tier
            operator: In
            values:
            - production          
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - mountPath: &quot;/var/www/html&quot;
      name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: volume-claim
</code></pre>
<p>My Volume is available but the PVC is <code>waiting for first consumer to be created before binding</code> which is expected since the Storage Class is set to <code>WaitForFirstConsumer</code>. But my pod is never scheduled, it gives the following warning:</p>
<pre><code>Warning  FailedScheduling  8m25s  default-scheduler  0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
</code></pre>
<p>If I remove the volume information from the yaml above, it deploys just fine so I don't know if it is a problem with the pod or something else. How do I get the pod to use the volumes?</p>

veda905
<p>Try:</p>
<pre><code>...
# Volume using a local filesystem
apiVersion: v1
kind: PersistentVolume
metadata:
  name: volume-pv
  labels:    # &lt;-- add for your PVC selector to match
    tier: production
...
</code></pre>
