赞
踩
静态pod 是由 kubelet 管理的只在特定node上存在的pod;静态pod总是由kubelet创建的,并且只在kubelet所在的Node上运行。
静态pod 不能通过 api-server来管理,无法和 RC,RS,Deployment或者 DaemonSet进行关联;
并且 kubelet无法对静态pod 进行健康检查。
创建静态pod
1、本地配置文件方式:
kubelet 启动时由 staticPodPath 指定的目录(默认/etc/kubernetes/manifests),kubelet会定期扫描这个目录,并根据这个目录下的 .yaml 或 .json 文件进行创建和更新操作
[root@k8s-master-1 ~]# systemctl cat kubelet # /usr/lib/systemd/system/kubelet.service [Unit] Description=kubelet: The Kubernetes Node Agent Documentation=https://kubernetes.io/docs/ Wants=network-online.target After=network-online.target [Service] ExecStart=/usr/bin/kubelet Restart=always StartLimitInterval=0 RestartSec=10 [Install] WantedBy=multi-user.target # /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf # Note: This dropin only works with kubeadm and kubelet v1.11+ [Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically --config=/var/lib/kubelet/config.yaml文件集中存在静态pod的配置目录,编辑查看: shutdownGracePeriodCriticalPods: 0s staticPodPath: /etc/kubernetes/manifests ### streamingConnectionIdleTimeout: 0s
编辑pod.yaml文件,如下:
---
apiVersion: v1
kind: Pod
metadata:
name: static-pod
lables:
app: nginx
spec:
containers:
- name: test-static
image: nginx:latest
ports:
- containerPort: 81
name: http-server
将此文件拷贝到 /etc/kubernetes/manifests目录下
查看pod。如下:
[root@k8s-master-1 ~]#
[root@k8s-master-1 ~]# kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
static-pod-k8s-master-1 1/1 Running 1 3h36m 10.244.0.7 k8s-master-1 <none> <none>
static-pod-k8s-node-1 1/1 Running 0 3h11m 10.244.1.2 k8s-node-1 <none> <none>
[root@k8s-master-1 ~]#
我在两个节点放了这个文件,所有会有两个pod,根据node进行区分。
要想删除pod,直接把yaml文件移走即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。