一个pod 两个容器:
[root@dock01 ~]# cat nginx-20210118.yaml
apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
restartPolicy: Never
volumes:
- name: shared-data
hostPath:
path: /data
containers:
- name: nginx-container
image: nginx
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
- name: debian-container
image: debian
volumeMounts:
- name: shared-data
mountPath: /pod-data
command: ["/bin/sh"]
args: ["-c", "echo Hello from the debian container 20210118 > /pod-data/index.html;sleep 3600"]
[root@dock01 ~]# kubectl create -f nginx-20210118.yaml
pod/two-containers created
[root@dock01 ~]# kubectl get pod two-containers -o wide
NAME READY STATUS REST