当前位置:  首页>> 技术小册>> Kubernets合辑7-存储

  1. [root@hdss7-200 volume]# vim /data/k8s-yaml/base_resource/volume/emptydir.yaml
  2. apiVersion: v1
  3. kind: Pod
  4. metadata:
  5. name: pod-emptydir
  6. namespace: app
  7. labels:
  8. tier: volume
  9. role: empty-dir
  10. spec:
  11. containers:
  12. - name: main-container
  13. image: harbor.od.com/public/busybox:v1.31.1
  14. volumeMounts:
  15. - name: web-root
  16. mountPath: /tmp
  17. command:
  18. - httpd
  19. args:
  20. - -f
  21. - -h
  22. - "/tmp/"
  23. - name: sidecar-container
  24. image: harbor.od.com/public/centos:7
  25. volumeMounts:
  26. - name: web-root
  27. mountPath: /tmp
  28. command:
  29. - /bin/bash
  30. args:
  31. - -c
  32. - "while :;do date +'%F %T' > /tmp/index.html;sleep 1;done"
  33. volumes:
  34. - name: web-root
  35. emptyDir: {}
  1. [root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/volume/emptydir.yaml
  2. [root@hdss7-21 ~]# kubectl get pod pod-emptydir -n app -o wide
  3. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  4. pod-emptydir 2/2 Running 0 71s 172.7.22.11 hdss7-22.host.com <none> <none>
  5. [root@hdss7-21 ~]# kubectl describe pod pod-emptydir -n app
  6. Name: pod-emptydir
  7. Namespace: app
  8. ...
  9. Containers:
  10. main-container:
  11. ...
  12. Mounts:
  13. /tmp from web-root (rw)
  14. ...
  15. sidecar-container:
  16. ...
  17. Mounts:
  18. /tmp from web-root (rw)
  19. ...
  20. Volumes:
  21. web-root:
  22. Type: EmptyDir (a temporary directory that shares a pod's lifetime)
  23. Medium:
  24. SizeLimit: <unset>
  25. [root@hdss7-21 ~]# while :;do curl -s 172.7.22.11;sleep 1;done
  26. 2020-01-26 12:31:09
  27. 2020-01-26 12:31:10
  28. 2020-01-26 12:31:11
  29. 2020-01-26 12:31:12

该分类下的相关小册推荐: