1、Infrastructure Container:基础容器
维护整个Pod网络空间,启动一个容器时,k8s会自动为我们启动一个基础容器
配置:
[root@k8s-node02 ~]# cat /opt/kubernetes/cfg/kubelet.conf |grep "infra-container-image" --pod-infra-container-image=lizhenliang/pause-amd64:3.0"
查看运行的基础容器
[root@k8s-node02 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES db342beb091f nginx "nginx -g 'daemon of…" 4 hours ago Up 4 hours k8s_nginx_nginx-deployment-b64b84b44-44qhn_default_b59e4505-35a3-4137-b9a5-150af624f473_0 7e65bf223ed4 lizhenliang/pause-amd64:3.0 "/pause" 4 hours ago Up 4 hours k8s_POD_nginx-deployment-b64b84b44-44qhn_default_b59e4505-35a3-4137-b9a5-150af624f473_0 3d61928d7119 ff281650a721 "/opt/bin/flanneld -…" 2 days ago Up 2 days k8s_kube-flannel_kube-flannel-ds-amd64-wcck5_kube-system_47e2c764-81fd-4157-a6e7-219f40e24dea_0 5bd45dd0d25b lizhenliang/pause-amd64:3.0 "/pause" 2 days ago Up 2 days k8s_POD_kube-flannel-ds-amd64-wcck5_kube-system_47e2c764-81fd-4157-a6e7-219f40e24dea_0
可以看到运行的每一个容器都有一个pause-amd64的基础容器自动会运行
2、InitContainers:初始化容器
先于业务容器开始执行,可以执行一些操作,具体使用方法如下:
apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp spec: containers: - name: myapp-container image: busybox:1.28 command: ['sh', '-c', 'echo The app is running! && sleep 3600'] initContainers: - name: init-myservice image: busybox:1.28 command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;'] - name: init-mydb image: busybox:1.28 command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
initContainers标签下的都是初始化容器的配置
3、业务容器
平时最常使用的容器