vlambda博客
学习文章列表

0154.K master初始化后_kube-proxy状态一直为CrashLoopBackOff处理记录


0. ENV




kubernetes 1.23.2。

多主多从架构部署。



1. 问题现象




第一个master初始化后,kube-proxy状态一直为CrashLoopBackOff状态

[root@rh-master01 ~]# kubectl get pod -n kube-systemNAME READY STATUS RESTARTS AGEcoredns-6d8c4cb4d-qxj5g 0/1 Pending 0 21mcoredns-6d8c4cb4d-z54tg 0/1 Pending 0 21metcd-rh-master01 1/1 Running 7 21mkube-apiserver-rh-master01 1/1 Running 7 21mkube-controller-manager-rh-master01 1/1 Running 11 21mkube-proxy-42hrz 0/1 CrashLoopBackOff 8 (4m58s ago) 21mkube-scheduler-rh-master01 1/1 Running 11 21m



2. 问题原因




1) 查看报错kube-proxy-42hrz日志

[root@rh-master01 ~]# kubectl -n kube-system logs kube-proxy-42hrzE0331 08:45:41.760830 1 run.go:74] "command failed" err="failed complete: unrecognized feature gate: SupportIPVSProxyMode"


2) 问题原因

对于 Kubernetes v1.10,“SupportIPVSProxyMode” 默认设置为 “true”。对于 Kubernetes v1.11及以后版本,该选项已完全删除。但是,您需要在v1.10之前为Kubernetes 明确启用 --feature-gates = SupportIPVSProxyMode = true。

[root@rh-master01 ~]# cat kubeadm-config.yaml          #查看集群初始化配置文件apiVersion: kubeproxy.config.k8s.io/v1alpha1kind: KubeProxyConfigurationfeatureGates: SupportIPVSProxyMode: true #配置了支持IPVS参数mode: ipvs



3. 问题处理




1) 查看ConfigMap

[root@rh-master01 ~]# kubectl get cm -n kube-systemNAME DATA AGEcoredns 1 27mextension-apiserver-authentication 6 27mkube-proxy 2 27mkube-root-ca.crt 1 27mkubeadm-config 1 27mkubelet-config-1.23 1 27m


2) 修改kube-proxy的ConfigMap配置

注释掉SupportIPVSProxyMode特性

[root@rh-master01 ~]# kubectl edit cm kube-proxy -n kube-system #注释下面两行,保存退出... 26 #featureGates: 27 # SupportIPVSProxyMode: true


3) 删除kube-proxy-xxxxx

kube-proxy-xxxxx更换为当前实际环境名称,如kube-proxy-42hrz。

[root@rh-master01 ~]# kubectl delete pod kube-proxy-42hrz -n kube-systempod "kube-proxy-42hrz" deleted


4) kube-proxy自动重启--问题解决

等待数秒,新的kube-proxy-fl45m状态为Running,运行正常。

[root@rh-master01 ~]# kubectl get pod -n kube-systemNAME READY STATUS RESTARTS AGEcoredns-6d8c4cb4d-qxj5g 0/1 Pending 0 30mcoredns-6d8c4cb4d-z54tg 0/1 Pending 0 30metcd-rh-master01 1/1 Running 7 30mkube-apiserver-rh-master01 1/1 Running 7 30mkube-controller-manager-rh-master01 1/1 Running 11 30mkube-proxy-fl45m 1/1 Running 0 2skube-scheduler-rh-master01 1/1 Running 11 30m



4. 小结




通过配置文件kubeadm-config.yaml对第一个master初始化时,由于配置了SupportIPVSProxyMode参数,在Kubernetes v1.11及以后版本去除了该参数,导致kube-proxy创建失败,通过将kube-proxy中的ConfigMap配置去掉SupportIPVSProxyMode相关特性,kube-proxy自动重建成功。当后续其它多主加入集群时,新kube-proxy也会创建成功。



5. 官方参考




https://kubernetes.io/zh/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/



- 完 -



旨在交流,不足之处,还望抛砖。




 


往期推荐