5

After restarting the VM, microk8s stopped running.

Executing this command outputs the following:
microk8s status:
microk8s is not running. use microk8s inspect for a deeper inspection.
microk8s kubectl get pod:
The connection to the server 127.0.0.1 16443 was refused did you specify the right host or port?

I have practically tried all the methods, but there is no result.

2 Answers2

3

Run ps -ef | grep kubelet

Output will be somewhat like this:

root 934 1 5 08:17 ? 00:20:40 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2

Look for path of kubelet.conf and then edit port in that file. On this port, kubelet connects with kube-apiserver. Once it's fixed, output of kubectl cluster-info should be somewhat like this:

Kubernetes control plane is running at https://192.168.56.2:6443 KubeDNS is running at https://192.168.56.2:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Avnish Gupta
  • 103
  • 1
  • 8
  • I changed the port, it still refers to 16443. When running the command: microk8s kubectl get pods: Connection to server 127.0.0.1 16443 was rejected did you specify the correct host or port? – Жека Михайленко May 17 '21 at 04:25
  • After making the changes, you need to restart the kubelet. `systemctl daemon-reload` `systemctl restart kubelet` – Avnish Gupta May 18 '21 at 10:47
  • Also you need to restart kubelets on all the nodes - master and worker nodes. For worker nodes, you need to ssh into them. – Avnish Gupta May 19 '21 at 16:21
2

Here the port is incorrect. It should be 6443 and not 16443. You can correct the port on master node in /etc/kubernetes/kubelet.conf file.

Avnish Gupta
  • 103
  • 1
  • 8