使用前提:
- K8S集群中正确部署了virtual-kubelet(serverless Kubernetes 默认集成)
ECI原生支持empty_dir,可以像原生K8S一样使用ECI的empty_dir,将以下内容保存为empty_dir.yaml:
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
# ACK场景下可以通过nodeName指定调度到ECI
# nodeName: virtual-node-eci-0
containers:
- image: nginx:latest
name: test-container
volumeMounts:
- mountPath: /cache-test
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
使用kubectl创建:
# kubectl create -f empty_dir.yaml
pod/test-pd created
# kubectl get pods
NAME READY STATUS RESTARTS AGE
test-pd 1/1 Running 0 61s
# kubectl exec -it test-pd bash
root@default-test-pd:/# ls
bin boot cache-test dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var