apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 volumeMounts: - name: nginx-config mountPath: /etc/nginx/nginx.conf # subPath: nginx.conf volumes: #指定到yaml配置文件里 - name: nginx-config configMap: name: confnginx # pod 容器之间共享文件 容器中的目录是mymount,物理机器对应目录是kubectl exec nginx(pod名称) mount|grep mymount 查看 dev/sda1 # pod 消亡共享目录就消亡 kubectl exec -it nginx(pod名称) /bin/bash # volumeMounts: # - mountPath: /mymount #pod 的mymount目录 # name: mount-volume #这个mount卷的名称,它是下面定义的 emptyDir 模式 # volumes: # - name: mount-volume # emptyDir: {} # 另外一种mount 另外一台机器做硬盘