【K8s故障排查】kubectl get componentstatuses 命令执行问题

K8s版本:1.20.8

问题描述:

# kubectl get componentstatuses
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"}

解决办法:

出现这种情况是kube-controller-manager.yaml和kube-scheduler.yaml设置的默认端口是0,在配置文件中注释掉“- --port=0”并重启服务就可以了。(每台master节点都要执行操作)

正常状态如下:

# kubectl get componentstatuses
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health":"true"}
posted @ 2021-08-10 09:43  Varden  阅读(1340)  评论(0编辑  收藏  举报