Last updated:2021-05-11 10:41:17
You can use local disk volumes in the following ways:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy:
type: Recreate
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:latest
imagePullPolicy: Always
name: nginx
volumeMounts:
- mountPath: /data
name: hostpath
volumes:
- hostPath:
path: /var
name: hostpath
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy:
type: Recreate
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:latest
imagePullPolicy: Always
name: nginx
volumeMounts:
- mountPath: /data
name: emptydir
volumes:
- emptyDir: {}
name: emptydir
Note:
If the source path of a local disk volume is empty, the system allocates a temporary directory, which is **/data/kubelet/pods/pod_id/volumes/kubernetes.io~empty-dir. **.
The lifecycle of the temporary local disk volume is the same as that of the associated pod.
Did you find the above information helpful?
Please give us your feedback.
Thank you for your feedback.