1

I have a fully functional MicroK8s running in my Hyper-V. After my host rebooted, I can't use microk8s kubectl anymore. I always get the following error:

microk8s kubectl get node -o wide

Unable to connect to the server: dial tcp 172.31.119.125:16443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

As I know, the master node IP been changed. If I update the KUBECONFIG locally, I can connect to cluster without problem.

microk8s config > ~/.kube/config

But if I want to use microk8s kubectl get node -o wide to get node status, I always can't get it working. I'm still unable to connect to the server.

I tried to clear all possible cache by removing all .kube/cache folders. But still not working.

sudo rm -rf /.kube/cache /root/.kube/cache /home/ubuntu/.kube/cache /var/snap/microk8s/3582/.kube/cache

I stopped and started MicroK8s again. I'm still unable to connect to the server.

microk8s stop
microk8s start

After MicroK8s restarted, I also tried to find out all files that contains 172.31.119.125 ip address.

grep '172.31.119.125' -r /

Nothing useful found. Only /var contains some logs with 172.31.119.125. That's so weird. Is there anything I can try? How to connect to MicroK8s using microk8s kubectl?

Will Huang
  • 2,955
  • 2
  • 37
  • 90

1 Answers1

1

After 1 hours deep dive, I finally realized there is a $env:LOCALAPPDATA\MicroK8s\config file used by MicroK8s which the doc never said.

All you need to do is the update the config file by the following ways:

PowerShell

microk8s config > $env:LOCALAPPDATA\MicroK8s\config

Command Prompt

microk8s config > %LOCALAPPDATA%\MicroK8s\config
Will Huang
  • 2,955
  • 2
  • 37
  • 90