kubeadm部署的k8s1.20版本get cs报错
**报错内容如下:**
```
[root@k8s-master1 ~]# 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"}
```
**原因:**
kubectl get cs这个在未来将会被弃用,官方没有出具相应的去做修复,虽然得到的结果是Unhealthy,但实际不影响使用,如果看不顺眼也是有解决办法的。
**解决办法:**
操作很简单,就是在master节点上操作编辑kube-controller-manager.yaml与kube-scheduler.yaml配置文件, 找到 **- --port=0** 这一行添加 **#** 号注释,取消该监听,最后重启 **kubelet** 服务即可。
```
cat /etc/kubernetes/manifests/kube-controller-manager.yaml
cat /etc/kubernetes/manifests/kube-scheduler.yaml
systemctl restart kubelet.service
```
```
[root@k8s-master1 ~]# 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"}
```
![image.png](https://s2.51cto.com/images/20210622/1624375016942644.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)