<p>Currently i try to implement <strong>PersistentVolume</strong> in my yaml file . 
I read a lot of documentation on internet and i dont understand why when i go to the dashboard pod i've  this message </p>

<blockquote>
  <p>persistentvolumeclaim "karaf-conf" not found</p>
</blockquote>

<p>pod.yaml</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: karafpod
spec:
  containers:
  - name: karaf
    image: xxx/karaf:ids-1.1.0
    volumeMounts:
    - name: karaf-conf-storage
      mountPath: "/apps/karaf/etc"
  volumes:
    - name: karaf-conf-storage
      persistentVolumeClaim:
        claimName: karaf-conf-claim
</code></pre>

<p><strong>PersistentVolumeClaimKaraf.yml</strong></p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: karaf-conf-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
</code></pre>

<p><strong>PersistentVolume.yaml</strong></p>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: karaf-conf
  labels:
    type: local
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/apps/karaf/etc"
</code></pre>

<p>You will find below the result of the command <strong>kubectl get pv</strong> </p>

<pre><code>NAME                             CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                         STORAGECLASS   REASON    AGE
karaf-conf                    100Mi      RWO            Retain           Terminating   default/karaf-conf-claim                            17h
karaf-conf-persistentvolume   100Mi      RWO            Retain           Released      default/karaf-conf                                  1h
</code></pre>

<p><strong>kubectl get pvc</strong></p>

<pre><code>NAME                  STATUS        VOLUME          CAPACITY   ACCESS MODES   STORAGECLASS   AGE
karaf-conf-claim   Terminating   karaf-conf   10Mi       RWO            manual         17h
</code></pre>

<p>With hostPath, you don't need PersistentVolume or PersistentVolumeClaim objects, so this might be easier depending on your need:</p>

<pre class="lang-yaml prettyprint-override"><code># file: pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: karafpod
spec:
  containers:
  - name: karaf
    image: xxx/karaf:ids-1.1.0
    volumeMounts:
    - name: karaf-conf-storage
      mountPath: "/apps/karaf/etc"  # Path mounted in container

  # Use hostPath here
  volumes:
    - name: karaf-conf-storage
      hostPath:
        path: "/apps/karaf/etc" # Path from the host
</code></pre>

<p>Then delete the other two .yaml files <code>PersistentVolumeClaimKaraf.yml</code> and <code>PersistentVolume.yml</code></p>

<p>For official documentation, see: <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#hostpath</a></p>

<p>Edit: Noticed that spec.containers.VolumeMounts.mountPath and spec.containers.volumes.hostPath.path from the original post were the same, so added comments in yaml to clarify purpose of each.</p>
