<p>I'm new to Kubernetes and I'm trying to add a PVC in my <code>StatefulSet</code> on Minikube.
PV and PVC are shown here:</p>
<pre><code>NAME            CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                      STORAGECLASS   REASON    AGE
neo4j-backups   5Gi        RWO            Retain           Bound     default/backups-claim      manual                   1h

NAME            STATUS    VOLUME          CAPACITY   ACCESS MODES   STORAGECLASS   AGE
backups-claim   Bound     neo4j-backups   5Gi        RWO            manual         51m
</code></pre>
<p>Basically I want all pods of the StatefulSet to see the contents of that volume as backup files are stored there.</p>
<p>StatefulSet used can be found <a href="https://github.com/neo4j-contrib/kubernetes-neo4j/blob/master/cores/statefulset.yaml" rel="nofollow noreferrer">here</a></p>
<p>Minikube version:
<code>minikube version: v0.25.2</code><br />
Kubernetes version: <code>GitVersion:&quot;v1.9.4&quot;</code></p>

<p>If you use <code>volumeClaimTemplates</code> in <code>StatefulSet</code> k8s will do dynamic provisioning &amp; create one PVC and corresponding PV for each pod, so each one of them gets their own storage. </p>

<p>What you want is to create one PV &amp; one PVC and use it in all replicas of Statefulset. </p>

<p>Below is example on Kubernetes 1.10 how you can do it, where <code>/var/www/html</code> will be shared by all three Pods, just change <code>/directory/on/host</code> to some local directory on your machine. Also I ran this example on minikube v0.26.0</p>

<p>Ofcourse below is just an example to illustrate the idea, but in a real example  processes in Pod should be aware of syncronizing access to shared storage. </p>

<hr>

<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 100Gi
  # volumeMode field requires BlockVolume Alpha feature gate to be enabled.
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /directory/on/host
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
                - minikube 
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: example-local-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: local-storage
---
apiVersion: "apps/v1beta1"
kind: StatefulSet
metadata:
  name: nginx
spec:
  serviceName: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx-container 
          image: "nginx:1.12.2"
          imagePullPolicy: "IfNotPresent"
          volumeMounts: 
            - name: localvolume
              mountPath: /var/www/html
      volumes:
        - name: localvolume
          persistentVolumeClaim:
            claimName: example-local-claim
</code></pre>
