Member-only story
Setting up Kubectl within Windows Subsystem Linux
WLS | Kubernetes | Windows | Linux | Ubuntu | AWS | Azure
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:
- 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.