网站开发过程的分工,潍坊logo设计公司,网站改版升级,资深的网站推广概念#xff1a;
初始化容器的概念 比如一个容器A依赖其他容器#xff0c;可以为A设置多个 依赖容易A1#xff0c;A2#xff0c;A3
A1,A2,A3要按照顺序启动#xff0c;A1没有启动启动起来的 话#xff0c;A2,A3是不会启动的#xff0c;直到所有的静态容器全 部启动完毕…概念
初始化容器的概念 比如一个容器A依赖其他容器可以为A设置多个 依赖容易A1A2A3
A1,A2,A3要按照顺序启动A1没有启动启动起来的 话A2,A3是不会启动的直到所有的静态容器全 部启动完毕主容器A才会启动。
一般用于A容器运行之前先做一些准备工作。 如果初始化容器失败则会一直重启pod不会创建 实战
yaml1
apiVersion: v1
kind: Pod
metadata:name: init-podlabels:app: init-pod
spec:containers:- name: init-podimage: busyboxcommand: [sh, -c, echo The app is running! sleep 3600]volumeMounts:- mountPath: /xxname: workdirinitContainers:- name: init-mkdirimage: busyboxcommand: [sh, -c, touch /work-dir/1112233]volumeMounts:- mountPath: /work-dirname: workdirvolumes:- name: workdiremptyDir: {}容器成功启动 yaml2
apiVersion: v1
kind: Pod
metadata:name: init-podlabels:app: init-pod
spec:containers:- name: init-podimage: busyboxcommand: [sh, -c, echo The app is running! sleep 3600]volumeMounts:- mountPath: /xxname: workdirinitContainers:- name: init-mkdirimage: busyboxcommand: [sh, -c, touch /work-dir/1112233 sleep 3600]volumeMounts:- mountPath: /work-dirname: workdirvolumes:- name: workdiremptyDir: {}在初始化容器里面加了sleep后容器无法正常启动一直是初始化状态
yaml3
apiVersion: v1
kind: Pod
metadata:name: init-podlabels:app: init-pod
spec:containers:- name: init-podimage: busyboxcommand: [sh, -c, echo The app is running! sleep 3600]volumeMounts:- mountPath: /xxname: workdirinitContainers:- name: init-mkdirimage: busyboxcommand: [sh, -c, touch1 /work-dir/1112233 sleep 3600]volumeMounts:- mountPath: /work-dirname: workdirvolumes:- name: workdiremptyDir: {}这里把command里面的touch故意改成touch1这样会报错测试如下所示