Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl connectivity issue

I installed first ectd, kubeapiserver and kubelet using systemd service. The services are running fine and listening to all required ports.

When I run kubectl cluster-info , I get below output

Kubernetes master is running at http://localhost:8080

When I run kubectl get componentstatuses, then I get below output

etcd-0               Healthy     {"health": "true"}

But running kubectl get nodes , I get below error

Error from server (ServerTimeout): the server cannot complete the requested operation at this time, try again later (get nodes)

Can anybody help me out on this.

like image 639
Rehan Ch Avatar asked Feb 09 '19 16:02

Rehan Ch


People also ask

How do I check Kubernetes connectivity?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.

How do I check my network issues with Kubernetes?

Tcpdump is a tool to that captures network traffic and helps you troubleshoot some common networking problems. Here is a quick way to capture traffic on the host to the target container with IP 172.28. 21.3. As you see there is a trouble on the wire as kernel fails to route the packets to the target IP.

Why kubectl is not working?

This occurs because the authentication credentials are not correctly set. To resolve this, copy the configuration file /etc/kubernetes/admin. conf to ~/. kube/config in a regular user account (with sudo if necessary) and try again.


1 Answers

For the message:

:~# k get cs
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"} 
--------

Modify the following files on all master nodes:

$ sudo vim /etc/kubernetes/manifests/kube-scheduler.yaml

Comment or delete the line:

- --port=0

in (spec->containers->command->kube-scheduler)

$ sudo vim /etc/kubernetes/manifests/kube-controller-manager.yaml

Comment or delete the line:

- --port=0

in (spec->containers->command->kube-controller-manager)

Then restart kubelet service:

$ sudo systemctl restart kubelet.service
like image 183
Mustapha EL GHAZI Avatar answered Oct 20 '22 22:10

Mustapha EL GHAZI