問題現(xiàn)象
部署完master節(jié)點(diǎn)以后,執(zhí)行kubectl get cs命令來(lái)檢測(cè)組件的運(yùn)行狀態(tài)時(shí),報(bào)如下錯(cuò)誤:
[root@k8s-master yum.repos.d]# kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME STATUS MESSAGE ERROR
scheduler Unhealthy Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused
controller-manager Unhealthy Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused
etcd-0 Healthy {"health":"true"}
[root@k8s-master yum.repos.d]# wget http://127.0.0.1:10251/healthz
--2020-11-14 00:10:51-- http://127.0.0.1:10251/healthz
Connecting to 127.0.0.1:10251... failed: Connection refused.
解決分析
出現(xiàn)這種情況绎签,是/etc/kubernetes/manifests/下的kube-controller-manager.yaml和kube-scheduler.yaml設(shè)置的默認(rèn)端口是0導(dǎo)致的缆毁,解決方式是注釋掉對(duì)應(yīng)的port即可,操作如下:
[root@k8s-master manifests]# ls
etcd.yaml kube-apiserver.yaml kube-controller-manager.yaml kube-scheduler.yaml
[root@k8s-master manifests]# pwd
/etc/kubernetes/manifests
[root@k8s-master manifests]#
kube-controller-manager.yaml文件修改:注釋掉27行,- --port=0
kube-scheduler.yaml配置修改:注釋掉19行,- --port=0
然后在master節(jié)點(diǎn)上重啟kubelet邑狸,systemctl restart kubelet.service懈糯,然后重新查看就正常了
[root@k8s-master manifests]# vim kube-controller-manager.yaml
[root@k8s-master manifests]# vim kube-scheduler.yaml
[root@k8s-master manifests]# vim kube-controller-manager.yaml
[root@k8s-master manifests]# systemctl restart kubelet.service
[root@k8s-master manifests]# kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health":"true"}