kuberneteswindows-subsystem-for-linuxkind

I can't reach my Kind cluster on WSL2 if I restart my computer, why?


I have a setup of WSL2 and Kind.

Whenever I restart my computer and open a new WSL2 window, I can no longer use kubectl to access my kind cluster.

 kind get clusters

 >>> kind

 kubectl config get-contexts

 CURRENT   NAME         CLUSTER      AUTHINFO     NAMESPACE
    *      kind-kind    kind-kind    kind-kind

 kubectl get pods

 >>> The connection to the server 127.0.0.1:40307 was refused - did you specify the right host or port?`

However, I can create a new kind cluster and access it.

 kind create cluster --name kind3

 kubectl get nodes

 NAME                  STATUS   ROLES           AGE     VERSION
 kind3-control-plane   Ready    control-plane   8m21s   v1.26.3

But if I restart my computer, once again I will not be able to access the cluster kind3

What am I doing wrong? Or what do I need to change in my configuration files to be able to access any old clusters after computer restart?


Solution

  • This is a known issue and has been mentioned in the github link. Can you check the WSL2 Version in Powershell or Windows Command Prompt by running wsl -l -v command. WSL2 v1.2.3/1.2.4 has the issue fixed. If the issue still persists with the 1.2.4 version run the following command on admin shell wsl --update --pre-release which has the fixed issue.