emptyDir
---
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
hostPath
---
# hostpath-example.yaml
apiVersion: v1
kind: Pod
metadata:
name: apiserver
spec:
containers:
- name: apiserver
image: zxcvbnius/docker-demo
volumeMounts:
- mountPath: /tmp
name: tmp-volume
imagePullPolicy: Always
volumes:
- name: tmp-volume
hostPath:
path: /tmp
type: Directory
kubectl create -f hostpath-example.yaml
kubectl exec -it apiserver sh
ls /tmp
echo "Hello World" > /tmp/test.txt
cat /tmp/test.txt
exit
NFS(Network FileSystem)
---
# nfs-example.yaml
apiVersion: v1
kind: Pod
metadata:
name: apiserver
spec:
containers:
- name: apiserver
image: zxcvbnius/docker-demo
ports:
- name: api-port
containerPort: 3000
volumeMounts:
- name: nfs-volumes
mountPath: /tmp
volumes:
- name: nfs-volumes
nfs:
server: {YOUR_NFS_SERVER_URL}
path: /
参考