<p>I have a 3-node Kubernetes cluster running on vagrant using the oracle Kubernetes vagrant boxes from <a href="http://github.com/oracle/vagrant-boxes.git" rel="nofollow noreferrer">http://github.com/oracle/vagrant-boxes.git</a>.</p>

<p>I want to add a pod including an Oracle database and persist the data so that in case all nodes go down, I don't lose my data.</p>

<p>According to how I read the Kubernetes documentation persistent volumes cannot be created on a local filesystem only on a cloud-backed device.  I want to configure the persistent volume and persistent volume claim on my vagrant boxes as a proof of concept and training exercise for my Kubernetes learning.</p>

<p>Are there any examples of how I might go about creating the PV and PVC in this configuration?</p>

<p>As a complete Kubernetes newbie, any code samples would be greatly appreciated.</p>

dnraikes
<p>Use host path:</p>

<p>create PV:</p>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data
</code></pre>

<p>create PVC:</p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>

<p>Use it in a pod:</p>

<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
       claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume" rel="nofollow noreferrer">documentation</a></p>

<p>This is just an example, for testing only.</p>

<p>For production use case, you will need dynamic provisioning using the  <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">StorageClass</a> for PVC, so that the volume/data is available when the pod moves across the cluster.</p>
