kubernetes initContainers
来源:原创
时间:2019-04-21
作者:脚本小站
分类:云原生
init Container 作用是为主容器进行初始化工作,使用 initContainers 字段定义初始化容器。初始化容器运行完成后主容器才会运行。
apiVersion: v1 kind: Pod metadata: name: init-container spec: containers: - name: nginx image: nginx:1.12 ports: - name: http containerPort: 80 volumeMounts: - name: html mountPath: /usr/share/nginx/html initContainers: - name: busybox image: busybox:1.28 command: ["/bin/sh","-c","echo 'html'> /usr/share/nginx/html/index.html"] volumeMounts: - name: html mountPath: /usr/share/nginx/html volumes: - name: html emptyDir: {}