<p>I'd like to set a Persistent Volume (pv and pvc), shared by pods in <a href="https://kind.sigs.k8s.io/" rel="nofollow noreferrer">Kind cluster</a>. But I need to keep the data persisted in my laptop (host server) as well, so the volume's path should be something in my laptop, which I can directly access it.</p>
<p>If I delete the <code>kind cluster</code>, the volume should be persisted, not be destroyed.</p>
<p>I hope to easily add or update in that volume or copy files out of it from my host laptop.</p>
<p>How can I let the pods know it in <code>KIND cluster</code>?</p>
<p>Paste my <code>kind.yaml</code> for your refernce</p>
<pre><code>$ kind
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
</code></pre>

<p>I would like to add that to minimise the specific configuration to <code>Kind</code> you should use <code>pv / pvc</code> this way the configuration on a real cluster will only differ in the definition of pv.</p>
<p>So if you configure extraMounts on your Kind cluster:</p>
<pre><code>apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
  extraMounts:
    - hostPath: /home/bill/work/www
      containerPath: /www
</code></pre>
<p>Then on that cluster create PV and PVC:</p>
<pre><code>---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-www
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 2Gi
  hostPath:
    path: /www/
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-www
spec:
  volumeName: pv-www
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
</code></pre>
<p>After that you can use it in deployment like this:</p>
<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      volumes:
      - name: www
        persistentVolumeClaim:
          claimName: pvc-www
      containers:
      - name: nginx
        image: nginx:1.14.2
        volumeMounts:
        - name: www
          mountPath: /var/www
</code></pre>
<p>As a result your local <code>/home/bill/work/www</code> will be mounted to <code>/var/www</code> inside containers.</p>
