自學(xué)k8s-kubeadm部署過(guò)程中遇到的dial tcp 127.0.0.1:10251: connect: connection refused錯(cuò)誤

問題現(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"}  
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容