Persistent Volume

Persistent volume is an independent storage resource with its own life cycle in kubernetes. It captures the implementation details of storage and abstracts them from where this gets used (through persistent volume claims). Persistent volume is implemented is same as volume such hostPath, nfs, emptyDir etc.

apiVersion: v1
kind: PersistentVolume
metadata:
    name: mypv
spec:
    accessModes:
        - ReadWriteOnce
    capacity:
        storage: 1Gi
    hostPath:
        path: /shared

Note

Persistent Volume are not namespaced. They are irrespective of namespaces. We can see that using command kubectl api-resources --namespaced=false This lists all the resources that are not namespaced.

References

  1. https://kubernetes.io/docs/concepts/storage/persistent-volumes/