Question
Create a PersistentVolume called pv-test with 8GB capacity. Set the access mode to ReadWriteMany. Any output from the container should be stored on the disk of underlying host at location /mnt/data.
Answer
You need to create PersistentVolume of type hostPath and set the path on the underlying host. By default, path is of type Directory:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
Apply and verify:
kubectl apply -f hp.yaml
kubectl describe pv pv-test