2 min read

Running Kubernetes CLI on Windows Subsystem for Linux (WSL)

Justin Yoo

Running Docker on Windows is easy. Running Docker in Windows Subsystem for Linux (WSL) needs some tricks. Nick Janetakis has well written the trick on his blog post. Now, I want to get Kubernetes running in WSL. As WSL doesn't support Docker running natively, neither does Kubernetes. But as always, there is a way.

In this post, I'm going to walk through how to run Kubernetes in WSL.

Installing Kubernetes via Docker for Windows - Edge Channel

First of all, we need to install the edge version of Docker for Windows. Go to settings > general then you will be able to see the current version running.

I have already installed the Edge version, so it shows my Docker for Windows is running the Edge version of it. Click the link in the red box.

And select the Edge channel. Then the Edge version will be installed. Once installed, another menu will be appearing – Kubernetes. Click the menu.

Kubernetes is not activated. Select the tick box and choose Kubernetes as an orchestration tool. Then click the Apply button for install.

Kubernetes has been installed and it's now up and running.

In order to check whether Kubernetes is running on Windows, enter the following command:

kubectl cluster-info

Now it's all done in the Windows side. Let's make that Kubernetes up and running in WSL.

Installing Kubernetes CLI in WSL

We have Kubernetes cluster working outside WSL. In order to get Kubernetes working in WSL, we need to install kubectl in WSL. In the bash screen, run the following command.

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ && chmod +x ./kubectl \ && sudo mv ./kubectl /usr/local/bin/kubectl

kubectl has been installed.

Copying Kubernetes Config from Windows

Even though kubectl has been installed, we can't use this until configuration is copied over. Enter the following command in the Bash prompt.

mkdir ~/.kube \ && cp /mnt/c/Users/[USERNAME]/.kube/config ~/.kube

If you have already completed this, you don't need /mnt bit any longer. Just use /c/Users/... instead.

And let kubectl know to use the Docker for Windows context.

kubectl config use-context docker-for-desktop

Now, kubectl in WSL should be working as expected. Enter the following command.

kubectl cluster-info

Deploying App to Kubernetes Cluster from WSL

Now, kubectl is basically up and running. But we need to make sure if it actually gets the deployment, service and pod running or not. Enter the command below:

kubectl run hello-minikube --image k8s.gcr.io/echoserver:1.10 --port 8080 kubectl expose deployment hello-minikube --type NodePort

Now the hello-minikube app is up and running. Run the following command to get the service port.

kubectl describe service hello-minikube

It says the service is open through the port number 32045. Open a web browser and access to the website.

We can see the website is up and running.


So far, we have walked through how to install and run Kubernetes in WSL. It doesn't require minikube any longer, which is much easier. I'm learning Docker and Kubernetes, and this will speed up my learning experiences.

If you still want to use minikube, you can follow Dario De Bastiani's post, Install kubernetes on windows + WSL.