[vagrant@kmaster ~]$ 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"}
And other commands everything works fine.
[ajeesh@kmaster ~]$ kubectl cluster-info
Kubernetes master is running at https://172.42.42.100:6443
KubeDNS is running at https://172.42.42.100:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
[ajeesh@kmaster ~]$ kubectl get pods --all-namespacesNAMESPACE NAME READY STATUS RESTARTS AGEkube-system calico-kube-controllers-56b44cd6d5-27smn 1/1 Running 0 6m43skube-system calico-kube-controllers-56b44cd6d5-g6gfw 0/1 NodeAffinity 0 118dkube-system calico-node-rv52x 1/1 Running 0 6m42skube-system calico-node-tq84v 1/1 Running 4 118dkube-system calico-node-wg8h9 1/1 Running 0 6m42skube-system coredns-f9fd979d6-69dhx 1/1 Running 2 118dkube-system coredns-f9fd979d6-rff6t 1/1 Running 2 118dkube-system etcd-kmaster.example.com 1/1 Running 3 118dkube-system kube-apiserver-kmaster.example.com 1/1 Running 3 118dkube-system kube-controller-manager-kmaster.example.com 1/1 Running 2 118dkube-system kube-proxy-7psvh 1/1 Running 2 118dkube-system kube-proxy-mf4hx 1/1 Running 2 118dkube-system kube-proxy-ndnk6 1/1 Running 2 118dkube-system kube-scheduler-kmaster.example.com 1/1 Running 2 118d[vagrant@kmaster ~]$
This issue is shown in my test Kubernetes cluster and while checking the kube-controller-manager.yaml and kube-scheduler.yaml 0 is the default port number used. So I have commented on that line and fixed the issue.
vi /etc/kubernetes/manifests/kube-controller-manager.yaml
- --leader-elect=true
- --node-cidr-mask-size=24
# - --port=0
- --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
vi /etc/kubernetes/manifests/kube-scheduler.yaml
- --kubeconfig=/etc/kubernetes/scheduler.conf
- --leader-elect=true
# - --port=0
image: k8s.gcr.io/kube-scheduler:v1.19.4
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 8
@kmaster vagrant]# service kubelet restart
@kmaster ~]$ 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"}