k8s创建静态pod
k8s创建静态pod静态Pod是由kubelet进行管理的仅存在于特定Node上的Pod。它们不能通过API Server进行管理,无法与ReplicationController、Deployment或者DaemonSet进行关联,并且kubelet无法对它们进行健康检查。静态Pod总是由kubelet创建的,并且总在kubelet所在的Node上运行。配置文件方式增加kubelet的配置文件–
·
k8s创建静态pod
静态Pod是由kubelet进行管理的仅存在于特定Node上的Pod。它们不能通过API Server进行管理,无法与ReplicationController、Deployment或者DaemonSet进行关联,并且kubelet无法对它们进行健康检查。静态Pod总是由kubelet创建的,并且总在kubelet所在的Node上运行。
配置文件方式
增加kubelet的配置文件
–pod-manifest-path=/etc/kubelet.d/
[root@tom ~]# cat /usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
#WorkingDirectory=/var/lib/kubelet
ExecStart=/usr/local/bin/kubelet --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice --address=192.168.11.110 --hostname-override=192.168.11.110 --cgroup-driver=cgroupfs --pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 --experimental-bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig --kubeconfig=/etc/kubernetes/kubelet.kubeconfig --cert-dir=/etc/kubernetes/ssl --cluster-dns=10.254.0.100 --cluster-domain=cluster.local. --hairpin-mode=promiscuous-bridge --allow-privileged=true --fail-swap-on=false --serialize-image-pulls=false --max-pods=30 --logtostderr=true --v=2 --pod-manifest-path=/etc/kubelet.d/
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
[root@tom ~]#
[root@tom ~]# cat /etc/kubelet.d/static-web.yaml
apiVersion: v1
kind: Pod
metadata:
name: static-web
labels:
role: myrole
spec:
containers:
- name: web
image: nginx:1.17.6
ports:
- name: web
containerPort: 80
protocol: TCP
[root@tom ~]#
[root@tom kubelet.d]# pod | grep static
default static-web-192.168.11.110 1/1 Running 1 44s 172.17.0.12 192.168.11.110 <none>
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]# docker ps | grep static
d4d4e32bd2d0 f7bb5701a33c "nginx -g 'daemon ..." About a minute ago Up About a minute k8s_web_static-web-192.168.11.110_default_2afff31d221bf0e43166ca6b119d7f08_1
dbfb901d1ca2 mirrorgooglecontainers/pause-amd64:3.0 "/pause" About a minute ago Up About a minute k8s_POD_static-web-192.168.11.110_default_2afff31d221bf0e43166ca6b119d7f08_1
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]# pod | grep static
default static-web-192.168.11.110 1/1 Running 1 3m7s 172.17.0.12 192.168.11.110 <none>
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]# kubectl delete pod static-web-192.168.11.110
pod "static-web-192.168.11.110" deleted
[root@tom kubelet.d]# pod | grep static
default static-web-192.168.11.110 0/1 Pending 0 1s <none> 192.168.11.110 <none>
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]# pod | grep static
default static-web-192.168.11.110 1/1 Running 1 21s 172.17.0.12 192.168.11.110 <none>
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
只有删除yaml文件才会删除pod
[root@tom kubelet.d]# mv static-web.yaml /
[root@tom kubelet.d]#
[root@tom kubelet.d]# ll
total 0
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]#
[root@tom kubelet.d]# pod | grep static
[root@tom kubelet.d]#
[root@tom kubelet.d]#
HTTP
失败
更多推荐
已为社区贡献4条内容
所有评论(0)