Photo by T K on Unsplash

Member-only story

Setting up Kubectl within Windows Subsystem Linux

WLS | Kubernetes | Windows | Linux | Ubuntu | AWS | Azure

βš— Kevin Summersill πŸ”‹
2 min readMar 11, 2022

--

You have needed Linux on your windows machine because PowerShell would not do what you needed to? Well, I also ran into this issue and needed to run Kubectl commands within my Ubuntu WSL2 Distro. So this article should be pretty simple. Let’s begin!

Now there are some prerequisites:

  1. Make sure that you have Kubectl Installed on your Distro.

Also, I will be running an Ubuntu distro. So if you are running ubuntu great if not please reference your distros commands.

Setting the KubeConfig Environment Variable

The first really easy method is to just set up the KUBECONFIG environment variable. Just point it to the location of your current config file and that's it. Usually by default when you install Kubectl it will install into a location like below:

export KUBECONFIG=/mnt/c/Users/<your-user>/.kube/config

Run the command above and you should now be able to run:

kubectl get nodes

Now when you run kubectl get nodes it will of course run the default context that you have in the file. If you wish to switch the context then run;

kubectl config use-context <name of context>

Well, that's pretty much it. Hope this quickly helps someone out when using WSL.

--

--

βš— Kevin Summersill πŸ”‹
βš— Kevin Summersill πŸ”‹

Written by βš— Kevin Summersill πŸ”‹

Enterprise Solution Architect | Certified K8s Administrator/Developer βš“ | SAFe SPC | Cert Terraform | AWS Solutions Architect | Dev*Ops/GitOps Engineer πŸ”₯

No responses yet