2

I have setup the Kubernetes cluster with Kubespray enter image description here

Once I restart the node and check the status of the node I am getting as below

$ kubectl get nodes
  The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?

enter image description here


Environment:

OS : CentOS 7
Kubespray
kubelet version: 1.22.3

Need your help on this.

Regards, Zain

Ali
  • 922
  • 1
  • 9
  • 24
Zainul1114
  • 61
  • 1
  • 4
  • kubelet process would have gone down after your shutdown. as root user you can run systemctl enable kubelet and systemctl start kubelet. which will enable the kubelet to get register to systemd process and on machine restart it will start the kubelet process – Nataraj Medayhal Oct 10 '22 at 11:35
  • i am unable to start kubelet services – Zainul1114 Oct 12 '22 at 09:24
  • Please run journalctl -xeu kubelet this will give reasons why the kubelet is failing when you start it – Nataraj Medayhal Oct 12 '22 at 13:08

4 Answers4

2

This work for me, I'm using minukube,

When checking the minikube status by running the command minikube status you'll probably get something like that

    E0121 07:14:19.882656    7165 status.go:415] kubeconfig endpoint: got: 
    127.0.0.1:55900, want: 127.0.0.1:49736

    type: Control Plane
    host: Running
    kubelet: Stopped
    apiserver: Stopped
    kubeconfig: Misconfigured

To fix it, I just followed the next steps:

  1. minikube update-context
  2. minukube start
BenSmile
  • 39
  • 3
0

Below step can solve your issue. kubelet may be down, use the below commands on the master node.

   1. sudo -i

   2. swapoff -a

   3. exit

   4. strace -eopenat kubectl version

Then try using kubectl get nodes.

Sai Chandra Gadde
  • 2,242
  • 1
  • 3
  • 15
  • i am not using Gcloud, this is on local setup ,can you suggest accordingly. – Zainul1114 Oct 12 '22 at 09:20
  • Can you go through this blog [Troubleshoot kubectl connection refused](https://medium.com/@texasdave2/troubleshoot-kubectl-connection-refused-6f5445a396ed) which can be helped to resolve your issue.Adding one more [link](https://www.thegeekdiary.com/troubleshooting-kubectl-error-the-connection-to-the-server-x-x-x-x6443-was-refused-did-you-specify-the-right-host-or-port/) – Sai Chandra Gadde Oct 12 '22 at 10:13
  • Thank you Sai for your inputs. i was getting `journalctl -xeu kubelet` output was `Error while dialing dial unix /var/run/cri-dockerd.sock: connect: no such file or directory` i did `sudo systemctl enable cri-dockerd.service` and `sudo systemctl restart cri-dockerd.service` then `sudo systemctl start kubelet` finally it works for me. `kubectl cluster-info` output `Kubernetes control plane is running at https://127.0.0.1:6443` https://github.com/kubernetes-sigs/kubespray/issues/8734 for more info. – Zainul1114 Oct 14 '22 at 04:30
0

Thank you Sai for your inputs. i was getting journalctl -xeu kubelet output was Error while dialing dial unix /var/run/cri-dockerd.sock: connect: no such file or directory i was restarted and enabled cri-dockerd services

  • sudo systemctl enable cri-dockerd.service
  • sudo systemctl restart cri-dockerd.service

then sudo systemctl start kubelet finally it works for me.

#kubectl cluster-info Kubernetes control plane is running at https://127.0.0.1:6443

this link will give https://github.com/kubernetes-sigs/kubespray/issues/8734 more info. Regards,Zain

Zainul1114
  • 61
  • 1
  • 4
0

Spin up a cluster first by running "minikube start" before creating pods. you seem not to have a cluster running thats the reason.

Solomon Sunday
  • 176
  • 1
  • 6