Skip to main content

Kubernetes Volumes

Similar to docker volumes, mount the volume to kubernetes pods. Moreover, it is not just limited to host volumes, kubernetes supports various types of volumes. Kubernetes Doc

apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /path/to/store/output
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: app-pv
operator: In
values:
- pandas-node
info

While using the local mount, it is mandatory to specify the nodeAffinity values and the make sure /path/to/store/output is created/exists. Unlike docker, kubernetes does not create host mount directories if not exists, because in kubernetes the local-storage could be one among disk, partition or directory.

caution

Though kubernetes supports local-storage, it is not a good practice to use it for production purpose because it is ephemeral and can be lost along with the node.