Pod为亲密性应用而存在
亲密性应用场景;
应用场景:
init产生的初始化配置,也是需要借助网络命名空间
或者文件系统
让主业务容器去使用
yaml示例:
apiVersion: v1
kind: Pod
metadata:
name: init-demo
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: workdir
mountPath: /usr/share/nginx/html
initContainers:
- name: install
image: busybox
command:
- wget
- "-O"
- "/work-dir/index.html"
- http://kubernetes.io
volumeMounts:
- name: workdir
mountPath: "/work-dir"
dnsPolicy: Default
volumes:
- name: workdir
emptyDir: {}
可以在空卷的挂载目录下查看到index.html内容。
静态Pod指的是固定在某个Node上,有kubelet管理生成的一种Pod
静态Pod的工作目录:/etc/kubernetes/manifests/
,里面默认有etcd.yaml
, kube-apiserver.yaml
,kube-controller-manager.yaml
,kube-scheduler.yaml
这几个pod,若想在某个节点上跑静态pod,只需要在该node节点上的静态pod工作目录下放yaml文件即可,若想删除该静态pod,则需要删除静态pod工作目录下的yaml即可。静态pod运行的名称后面就会跟有节点名称:
若想更改工作目录,则需要去/var/lib/kubelet/config.yaml
修改配置,将staticPodPath
后面的路径改为其他,重启kubelet服务即可生效
静态pod特点:
yaml示例:
apiVersion: v1
kind: Pod
metadata:
name: static-pod
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:kubernetes Init Container与静态Pod简介