在K8s集群中使用下面命令查看当前集群不健康
kuebe get cs NAME STATUS MESSAGE ERROR controller-manager Healthy Unhealthy Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252 scheduler Healthy Unhealthy Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10251 etcd-0 Healthy {"health":"true"}
查看k8s的controller-manager组件中有如下报错
controller-manager Unhealthy Get “http://127.0.0.1:10252/healthz”: dial tcp 127.0.0.1:10252: connect: connection refused scheduler Unhealthy Get “http://127.0.0.1:10251/healthz”: dial tcp 127.0.0.1:10251: connect: connection refused
然后可以通过下述方法解决
修改/etc/kubernetes/manifests/下的kube-controller-manager.yaml和kube-scheduler.yaml文件
注释掉这两个文件中的- --port=0这条参数即可恢复,修改完组件会自动进行重启,无需手动再次重启。
然后再次执行命令检查,发现集群已经正常