k8s 集群 kubelet日志报错 command failed" err="failed to parse kubelet flag: unknown flag: --network-plugin
背景描述:
- 在k8s 集群get nodes出现
E0408 15:31:50.400954 23612 memcache.go:265] couldn't get current server API group list: Get " https:// 192.168.0.20:6443/api? timeout=32s ": dial tcp 192.168.0.20:6443: connect: connection refused
- 查看kubelet服务状态
systemctl status kubelet.service
发现服务处于loaded状态,kubelet.service entered failed state.
- 查看kubelet日志
journalctl -u kubelet -f
Apr 08 16:57:15 master kubelet[27951]: E0408 16:57:15.786948 27951 run.go:74] "command failed" err="failed to parse kubelet flag: unknown flag: --network-plugin"
问题解决
根据日志可以初步判断,应该是cni网络模块除了问题,kebelet重启后,启动网络插件的命令无法执行。
之后分别在master和node节点上查看下kubelet的版本,结果发现了问题:
rpm -qa | grep kube
- 即master节点的kubeadm、kubelet、kubernetes-cni、kubectl和node节点的版本不一致,且master节点使用的版本的高于node节点。即尝试,将master节点的kubeadm、kubelet、kubernetes-cni、kubectl版本降级至与node节点一致。
yum downgrade kubernetes-cni-0.8.7-0.x86_64 kubeadm-1.17.4-0.x86_64 kubectl-1.17.4-0.x86_64 kubelet-1.17.4-0.x86_64
- 重启kubelet
sudo systemctl restart kubelet.service
systemctl daemon-reload
- 查看kubelet的状态,kubelet服务 active (running)
- 查看kubelet日志,正常
- get nodes、get pod均正常
Resolved!
参考博客: