Friday, December 05, 2025

Make WSL use Rancher Desktop kubeconfig

 

✅ 1. First: Check the kubeconfig Rancher Desktop injects into Windows

Rancher Desktop ALWAYS writes a kubeconfig to this standard location:

👉 C:\Users\<your-user>\.kube\config

Check it:

PowerShell:

dir $HOME\.kube

If you see a file named config, then that is the correct kubeconfig.


eg: 

Directory: C:\Users\admin\.kube

Mode                 LastWriteTime         Length Name

----                 -------------         ------ ----

d-----        22/11/2024  10:12 AM                cache
-a----        06/12/2025   8:58 AM           6054 config



Inside WSL run:

mkdir -p ~/.kube ln -s /mnt/c/Users/admin/.kube/config ~/.kube/config

Now WSL and PowerShell use the same Kubernetes context.


Create aliases for convenience

Inside WSL, so you don’t have to type .exe:

echo "alias kubectl='kubectl.exe'" >> ~/.bashrc echo "alias helm='helm.exe'" >> ~/.bashrc source ~/.bashrc

Now in WSL you can run:

kubectl get nodes helm list -A

Exactly like in PowerShell.


No comments: