其他分享
首页 > 其他分享> > |NO.Z.00014|——————————|CloudNative|——|KuberNetes&书签.V14|--------------------------------------------

|NO.Z.00014|——————————|CloudNative|——|KuberNetes&书签.V14|--------------------------------------------

作者:互联网



[CloudNative:KuberNetes&书签.V14]                                                                      [Applications.KuberNetes]








报错处理四:
### --- 报错现象:kubelet无法启动排查

[root@k8s-master01 ~]# systemctl status kubelet
● kubelet.service - Kubernetes Kubelet
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubelet.conf
   Active: inactive (dead) since Thu 2021-07-15 19:25:09 CST; 1s ago
     Docs: https://github.com/kubernetes/kubernetes
  Process: 1518 ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_SYSTEM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 1518 (code=exited, status=0/SUCCESS)
### --- 报错分析:

~~~     ——>先停止当前窗口的kubelet: systemctl stop kubelet
~~~     ——>新开一个窗口,输入tail -f /var/log/messages,敲20次回车,保持窗口清洁
~~~     ——>第一个窗口执行systemctl start kubelet , 然后立即在另一个窗口执行ctrl + c终止tail
~~~     ——>此时第二个窗口会报大量无法启动的日志,如下:
~~~     ——>Jan 19 21:53:42 k8s-node01 kubelet: F0119 21:53:42.995488     405 server.go:269] failed to run Kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
~~~     ——>可以看到F开头或者E开头的为错误日志,后面为错误日志。
~~~     此处报错为kubelet和docker的cgroup类型不一样(你的报错可能不一样,需要自行查看错误信息),需要修改为一样的。
### --- 解决方案:
~~~     # 确认docker是否为systemd
~~~     注:如果不是systemd,或者没有该文件,请创建该文件。

[root@k8s-node01 ~]# cat /etc/docker/daemon.json 
{
  "exec-opts": ["native.cgroupdriver=systemd"]
}
[root@k8s-node01 ~]# rm -rf /var/lib/docker 
[root@k8s-node01 ~]# systemctl daemon-reload
[root@k8s-node01 ~]# systemctl restart docker
~~~     # 通过docker info确认

[root@k8s-node01 ~]# docker info | grep Driver
 Storage Driver: overlay2
 Logging Driver: json-file
 Cgroup Driver: systemd
~~~     # 修复kubelet
~~~     将/etc/kubernetes/kubelet-conf.yml文件的cgroupDriver改成systemd
~~~     (要与docker的一致,无法docker的无法更改为systemd,请改为和docker的一样的)。
~~~     然后执行(无论kubelet-conf.yml是不是systemd都要执行)

[root@k8s-node01 ~]# systemctl stop kubelet
[root@k8s-node01 ~]# systemctl daemon-reload
[root@k8s-node01 ~]# rm -rf /var/lib/kubelet/*
[root@k8s-node01 ~]# systemctl restart kubelet
~~~     # 再次查看即可恢复

[root@k8s-master01 ~]# systemctl status kubelet
● kubelet.service - Kubernetes Kubelet
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubelet.conf
   Active: active (running) since Thu 2021-07-15 19:25:25 CST; 5min ago
     Docs: https://github.com/kubernetes/kubernetes
 Main PID: 62868 (kubelet)
    Tasks: 18
   Memory: 72.3M
   CGroup: /system.slice/kubelet.service
           └─62868 /usr/local/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.kubeconfig --kubeconfig=/etc/kubernetes/kubelet.kubeconfig --config=/etc/kubernetes/kubele...








===============================END===============================


Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart                                                                                                                                                   ——W.S.Landor



来自为知笔记(Wiz)

标签:systemd,node01,V03,KuberNetes,kubelet,报错,docker,k8s,root
来源: https://www.cnblogs.com/yanqivip/p/16067308.html