01、问题描述

使用kubectl get cs查看K8s组件状态,发现scheduler和controller-manager状态为Unhealthy,但集群可以正常使用。

[root@k8s-master ~]# 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"}  

02、解决方式

健康检查报错,10250和10251端口不存在,开启scheduler, control-manager的10251,10252端口即可。

(1)修改以下配置文件:

静态pod的路径:/etc/kubernetes/manifests

将kube-scheduler.yaml和kube-controller-manager.yaml,把port=0那行注释

[root@k8s-master ~]# cd /etc/kubernetes/manifests/
[root@k8s-master manifests]# vi kube-scheduler.yaml 

vi kube-controller-manager.yaml

(2)无需重启即可生效,使用kubectl get cs重新查看组件状态,显示正常。

[root@k8s-master manifests]# 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社区为您提供最前沿的新闻资讯和知识内容

更多推荐