该文章记录自己在学习使用K8S过程,遇到过的问题与解决方法,与大家分享之。

1. Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused

现象

[root@t20 ~]# kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME                 STATUS      MESSAGE                                                                                       ERROR
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   
etcd-0               Healthy     {"health":"true"}      

解决: 在每台master节点上进行以下操作

[root@t20 ~]# cat  /etc/kubernetes/manifests/kube-scheduler.yaml 
...
16     - --bind-address=127.0.0.1
17     - --kubeconfig=/etc/kubernetes/scheduler.conf
18     - --leader-elect=true
19   #  - --port=0    # 注释掉该行


[root@t20 ~]# cat /etc/kubernetes/manifests/kube-controller-manager.yaml 
...
24     - --kubeconfig=/etc/kubernetes/controller-manager.conf
25     - --leader-elect=true
26  #   - --port=0   # 注释掉该行


[root@t20 ~]# systemctl restart kubelet

查看:

[root@t20 ~]# kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME                 STATUS    MESSAGE             ERROR
controller-manager   Healthy   ok                  
scheduler            Healthy   ok                  
etcd-0               Healthy   {"health":"true"} 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐