Running kubectl Commands Locally in WSL
To run kubectl commands from your local machine via WSL:
- Go into the cluster in Rancher and either download the KubeConfig or copy it.

- Create a new file in the
~/.kubedirectory calledconfigorconfig-clusternameand either import or paste the downloaded/copied KubeConfig. - Run the following command to activate a specific config:
export KUBECONFIG=~/.kube/config
OR
export KUBECONFIG=~/.kube/config.dev
Before/after output:
jeff@FS-25097:~/.kube$ export KUBECONFIG=~/.kube/config.dev
jeff@FS-25097:~/.kube$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
pbg1aiw20d100.mfg.fs Ready worker 691d v1.34.6+rke2r3
pbg1aiw20d101.mfg.fs Ready worker 692d v1.34.6+rke2r3
pbg1aiw20d102.mfg.fs Ready worker 692d v1.34.6+rke2r3
pbg1con20s550 Ready control-plane,etcd,master 693d v1.34.6+rke2r3
pbg1con20s551 Ready control-plane,etcd,master 694d v1.34.6+rke2r3
pbg1con20s552 Ready control-plane,etcd,master 694d v1.34.6+rke2r3
pbg1con20s600.mfg.fs Ready postgres,worker 694d v1.34.6+rke2r3
pbg2con20s600.mfg.fs Ready postgres,worker 694d v1.34.6+rke2r3
jeff@FS-25097:~/.kube$ export KUBECONFIG=~/.kube/config
jeff@FS-25097:~/.kube$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
aks-mfgdsgen-39770326-vmss000022 Ready <none> 7d4h v1.35.8
aks-mfgdsgen-39770326-vmss000024 Ready <none> 26h v1.35.8
aks-mfgdsmod-99929960-vmss00011l Ready <none> 40m v1.35.8
aks-mfgdspg-20345190-vmss000000 Ready <none> 7d5h v1.35.8
aks-mfgdspg-20345190-vmss000001 Ready <none> 7d5h v1.35.8
aks-mfgdspg-20345190-vmss000002 Ready <none> 7d5h v1.35.8
aks-postgres-31419873-vmss000004 Ready <none> 7d6h v1.35.8
aks-postgres-31419873-vmss000005 Ready <none> 7d6h v1.35.8
aks-postgres-31419873-vmss00000j Ready <none> 7d5h v1.35.8
aks-system-32067286-vmss00001p Ready <none> 7d6h v1.35.8
aks-system-32067286-vmss00002m Ready <none> 7d6h v1.35.8
aks-system-32067286-vmss00002q Ready <none> 7d6h v1.35.8