There are a lot of volume types in Kubernetes. And I most working with following volume types.
emptyDir
apiVersion: v1
kind: Pod
metadata:
name: busypod
spec:
containers:
- name: write
image: busybox
command: ["bash","-c","for i in {1..100};do echo $i >> /data/hello;sleep 1;done"]
volumeMounts:
# mount data volume to /data folder
- name: data
mountPath: /data
- name: read
image: centos
command: ["bash","-c","tail -f /data/hello"]
volumeMounts:
# mount data volume to /data folder
- name: data
mountPath: /data
# define a volume
volumes:
# volume name 'data'
- name: data
emptyDir: {}
hostPath
apiVersion: v1
kind: Pod
metadata:
name: busy-pod
spec:
containers:
- name: busybox
image: busybox
args:
- /bin/sh
- -c
- sleep 36000
volumeMounts:
# mount data volume to /data in the container
- name: data
mountPath: /data
volumes:
- name: data
# mount /tmp directory from host machine to pod
hostPath:
path: /tmp
type: Directory
There are a lot of volume types in Kubernetes. And I most working with following volume types.
emptyDir
hostPath
NFS
PV