查看master组件状态时出现错误

[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"}                                                                             

一开始没有发现这错误,网上查找后发现,是由于kube-controller-manager.yaml和kube-scheduler.yaml中的默认端口为0,只需要将其对应的port端口注释后,重新apply即可

[root@k8s-master ~]# cd /etc/kubernetes/manifests/
[root@k8s-master manifests]# ls
etcd.yaml  kube-apiserver.yaml  kube-controller-manager.yaml  kube-scheduler.yaml
[root@k8s-master manifests]# vim kube-controller-manager.yaml
[root@k8s-master manifests]# vim kube-scheduler.yaml
vim kube-controller-manager.yaml

vim kube-scheduler.yaml

 修改后重新apply后即可

[root@k8s-master manifests]# kubectl apply -f kube-scheduler.yaml
pod/kube-scheduler created
[root@k8s-master manifests]# kubectl apply -f kube-scheduler.yaml
pod/kube-scheduler configured
[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"}

参考博客:

https://blog.csdn.net/liufuling14/article/details/120629842

https://blog.csdn.net/wuyong15221125927/article/details/113085922

个人学习总结,仅供参考

Logo

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

更多推荐