<p>I'm getting started with persistent volumes and k8s. Im trying to use a local folder on my RH7 box w minikube installed. Im getting the error:</p>

<pre><code>0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.
</code></pre>

<p>StorageClass.yaml</p>

<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
</code></pre>

<p>PersistentVolume.yaml</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-local-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /usr/local/docker/vol1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - my-node
</code></pre>

<p>PersistentVolumeClaim.yaml</p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: example-local-claim
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: local-storage
  resources:
    requests:
      storage: 1Gi
</code></pre>

<p>Nginx.yaml</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
    name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
      name: nginx-deployment
  template:
    metadata:
      labels:
        app: nginx
        name: nginx-deployment
    spec:
      containers:
      - name: nginx-deployment
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: storage
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: example-local-claim
</code></pre>

<p>[root@localhost docker]# kubectl get pv</p>

<pre><code>NAME               CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS    REASON   AGE
example-local-pv   1Gi        RWO            Retain           Available           local-storage            76s
</code></pre>

<p>[root@localhost docker]# kubectl get pvc</p>

<pre><code>NAME                  STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS    AGE
example-local-claim   Pending                                      local-storage   75s
</code></pre>

encore02
<p>The issue is in your persistent volume, your persistent volume has following node selector:</p>

<pre><code>nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - my-node
</code></pre>

<p>where your PV is trying to bind on node whose name is <code>my-node</code>, which it couldn't find as there is no node with that name. Please check your node-name using:</p>

<p><code>kubectl get nodes</code></p>

<p>And put the node name at the place of <code>my-node</code> and it will work. Hope this helps.</p>
