apiVersion: v1
kind: Pod
metadata:
  name: pod-local-pvc
spec:
  restartPolicy: Never
  containers:
    - image: ubuntu
      name: ubuntu-container
      command: ['/bin/bash', '-ec', 'cat /data/application/data.txt']
      volumeMounts:
        - mountPath: /data/application
          name: local-volume
  volumes:
    - name: local-volume
      persistentVolumeClaim:  # This is the type of volume.
        claimName: pvc-local  # Kubernetes will:
                              #   - look for a bound PVC with this claim name.
                              #   - mount the volume at the mountPath given in this pod yaml
                              #   The pod and the PVC have to be in the same namespace.
                              #   If a PVC is not found, the pod will not be scheduled,
                              #   and will remain in a Pending state until deleted.

# kubectl create -f pod-local-pvc.yaml
# kubectl get pod pod-local-pvc  # Shows Ready status 0/1. Check logs.
# kubectl logs pod-local-pvc     # Shows "Data written on host"
# kubectl delete pod pod-local-pvc
# kubectl delete pvc pvc-local
# kubectl delete pv pv-hostpath

