PV PVC

volume

PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: myvolume
  labels:
    type: local
spec:
  storageClassName: normal
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/etc/foo"

PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  storageClassName: normal
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

Pod1 with PVC

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: mypvc
  containers:
  - args:
    - sh
    - -c
    - sleep 3600
    image: busybox
    name: busybox
    resources: {}
    volumeMounts:
      - mountPath: "/etc/foo"
        name: task-pv-storage
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

Pod2 with PVC

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox-toobusy
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: mypvc
  containers:
  - args:
    - sh
    - -c
    - sleep 3600
    image: busybox
    name: busybox
    resources: {}
    volumeMounts:
      - mountPath: "/etc/foo"
        name: task-pv-storage
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}