如何恢復?
首先,要淡定,卸載了kubelet後,影響的範圍:本節點和apiserver的雙向通信,不能和apiserver通信,會導致docker容器無法啟動。
docker ps -a
發現沒有一個自啟的容器
重新安裝kubelet後,發現docker容器還是無法啟動。說明沒有連接上配置文件。
ps -ef | grep kubelet
/usr/bin/kubelet
然而正常的kubelet節點上面是有很多參數的,
root 1334106 1 7 12:56 ? 00:06:56 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=cgroupfs --cni-bin-dir=/opt/cni/bin --cni-conf-dir=/etc/cni/net.d --network-plugin=cni --read-only-port=10255 --cni-bin-dir=/opt/cni/bin --cni-conf-dir=/etc/cni/net.d --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.1
發現僅僅是服務起來了,沒有關聯到任何參數,肯定是啟動配置文件的問題
啟動參數文件1: /usr/lib/systemd/system/kubelet.service
啟動參數文件2: /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
[root@master-03 ~]# cat /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
# kubelet連接apiserver的證書文件
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
# kubelet的配置參數,裡面有指定靜態pods的路徑。
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
# 這個文件是 "kubeadm init" and "kubeadm join"在運行時生成的文件,動態生成的。主要依賴於kubeadm的配置文件裡面的配置
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
# 新增啟動配置參數
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
啟動參數文件3:/etc/sysconfig/kubelet
[root@master-03 ~]# cat /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS= --read-only-port=10255 --cni-bin-dir=/opt/cni/bin --cni-conf-dir=/etc/cni/net.d --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.1
發現啟動參數文件2和啟動參數文件3裡面沒有數據
然後拷貝一份數據過來,重啟kubelet後發現恢復正常
關鍵字: Environment 卸載 This