<p>My PersistentVolumeClaim will not use the PersistentVolume I have prepared for it.</p>

<p>I have this <code>PersistentVolume</code> in <code>monitoring-pv.yaml</code></p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: monitoring-volume
  labels:
    usage: monitoring
spec:
  capacity:
    storage: 50Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /data/k8data/monitoring
</code></pre>

<p>After I have done </p>

<pre><code>kubectl apply -f monitoring-pv.yaml 
</code></pre>

<p>I can check that it exists with <code>kubectl get pv</code></p>

<pre><code>NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                                     STORAGECLASS   REASON    AGE
monitoring-volume                          50Gi       RWO            Retain           Available                                                                        5m
</code></pre>

<p>My <code>PersistentVolumeClaim</code> in <code>monitoring-pvc.yaml</code> looks like this:</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: monitoring-claim
  namespace: monitoring
spec:
  storageClassName: manual
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
  selector:
    matchLabels:
      usage: monitoring    
</code></pre>

<p>When I do <code>kubectl apply -f monitoring-pvc.yaml</code> it gets created.</p>

<p>I can look at my new <code>PersistentVolumeClaim</code> with <code>get pvc -n monitoring</code>and I see</p>

<pre><code>NAME                           STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
monitoring-claim               Pending                                                                        manual         31s
</code></pre>

<p>When I look at my <code>PersistentVolume</code> with <code>kubectl get pv</code> I can see that it's still available:</p>

<pre><code>NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                                     STORAGECLASS   REASON    AGE
monitoring-volume                          50Gi       RWO            Retain           Available                                                                        16m
</code></pre>

<p>I had expected the <code>PersistentVolume</code> to be <code>Bound</code>but it isn't. When I use a ´PersistentVolumeClaim´ with the same name as this, a new <code>PersistentVolumeClaim</code> is created that is written in <code>/tmp</code> and therefore not very persistent.</p>

<p>When I do the same operations without a namespace for my <code>PersistentVolumeClaim</code> everything seems to work.</p>

<p>I'm on minikube on a Ubuntu 18.04.</p>

<p>What do I need to change to be able to connect the volume with the claim?</p>

Thomas Sundberg
<p>When I reviewed my question and compared it to a working solution, I noticed that I had missed <code>storageClassName</code> that was set to <code>manual</code> in an example without a namespace that I was able to use.</p>

<p>My updated <code>PersistentVolume</code>now looks like this:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: monitoring-volume
  labels:
    usage: monitoring
spec:
  storageClassName: manual
  capacity:
    storage: 50Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /data/k8data/monitoring
</code></pre>

<p>The only difference is</p>

<pre><code>  storageClassName: manual
</code></pre>

<p>My preliminary findings is that this was the silly mistake I had done.</p>
