12

I'm getting following error message:

root@master-1:~# microk8s.kubectl get no
The connection to the server 127.0.0.1:16443 was refused - did you specify the right host or port?

Even microk8s.kubectl cluster-info dump fails with message above. When I run microk8s start it still the same.

hejkerooo
  • 709
  • 2
  • 7
  • 20
  • 1
    Two questions: 1. Is swap turned off? 2. Have you checked if the kubeconfig file is present? (`$HOME/.kube/config`) – Wytrzymały Wiktor Oct 05 '20 at 10:48
  • to be able to help you first provide accurate information how you spinned up/configured cluster. Not enough info to help at all.. – Vit Feb 22 '21 at 09:40

4 Answers4

4

It is hard to tell exactly what might went wrong here but there are few things that you could do in order to fix your issue:

  • .kube/config is missing or not configured correctly. Create or copy a valid kubeconfig file to solve this.

  • You have swap not turned off. With swap enabled, kubelet service will not start. Execute: sudo swapoff -a in order to make sure it is disabled.

  • kubelet might be down. Check kubelet logs and make sure that kube-apiserver is up and running.

  • Check which ports are appropriate to use with the telnet command.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
0

check your /etc/ hosts file there should be these lines

127.0.0.1 localhost 127.0.1.1 name you servers

  • 127.0.0.1 is already an ip address, it's not related to hosts file – Pezhvak Apr 12 '21 at 11:49
  • @Pezhvak 127.0.0.1 is a special, reserved IP address. It is called the loopback address. The hostname localhost is used for 127.0.0.1 and it's normal to see a couple of lines relating 127.0.0.1 to localhost and to the host name. – Jeter-work Apr 02 '22 at 05:52
0

iptables were provisioned by ansible which were messing with microk8s iptables configuration

hejkerooo
  • 709
  • 2
  • 7
  • 20
0

For me Ubuntu 20.04.4 LTS (Focal Fossa), this two commands save my day:

sudo microk8s.refresh-certs --cert ca.crt

and

sudo microk8s.refresh-certs --cert server.crt
Ali
  • 922
  • 1
  • 9
  • 24