A temporary path is of the Kubernetes-native emptyDir type. Its lifecycle is the same as that of a pod. Memory can be specified as the storage medium. When the pod is deleted, the emptyDir volume is deleted and its data is lost.
Parameter |
Description |
---|---|
Storage Medium |
Memory:
NOTE:
|
Mount Path |
Enter a mount path, for example, /tmp. This parameter indicates the container path to which a data volume will be mounted. Do not mount the volume to a system directory such as / or /var/run. Otherwise, containers will be malfunctional. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. Otherwise, the files will be replaced, causing container startup failures or workload creation failures.
NOTICE:
If the container is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged. |
Subpath |
Enter the subpath of the storage volume and mount a path in the storage volume to the container. In this way, different folders of the same storage volume can be used in a single pod. tmp, for example, indicates that data in the mount path of the container is stored in the tmp folder of the storage volume. If this parameter is left blank, the root path is used by default. |
Permission |
|
vi nginx-emptydir.yaml
Content of the YAML file:
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-emptydir namespace: default spec: replicas: 2 selector: matchLabels: app: nginx-emptydir template: metadata: labels: app: nginx-emptydir spec: containers: - name: container-1 image: nginx:latest volumeMounts: - name: vol-emptydir # Volume name, which must be the same as the volume name in the volumes field. mountPath: /tmp # Path to which an EV is mounted. imagePullSecrets: - name: default-secret volumes: - name: vol-emptydir # Volume name, which can be customized. emptyDir: medium: Memory # EV disk medium: If this parameter is set to Memory, the memory is enabled. If this parameter is left blank, the native default storage medium is used. sizeLimit: 1Gi # Volume capacity.
kubectl apply -f nginx-emptydir.yaml