This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.
The Problem
So recently I was trying to run some kubectl commands using WSL2 to my home K8S cluster and encountered some strange events. Everything had worked fine when using WSL but for some reason I could now only ping external devices to my laptop (Router, Switch, Printer etc).
My Configuration
So just for clarification I have my configuration set like this.
- My local network runs a 192.168.1.0/24 subnet.
- My laptop runs as 192.168.1.10.
- Hyper-V installed on the laptop.
- WSL2 installed and running Ubuntu 18.04.
- WSL vSwitch configured in Hyper-V Virtual Switch Manager as "Internal Network".
- Hyper-V configured with a dedicated vSwitch for Kubernetes (K8s-Switch).
- Set as "Internal Network".
- 3 x Ubuntu 18.04 Kubernetes VMs configured below.
- k8s-master-01 (10.10.10.101/24).
- k8s-worker-01 (10.10.10.111/24).
- k8s-worker-02 (10.10.10.112/24).
The worker and the nodes are all configured to route traffic correctly and can actively ping my host and resolve external domains.
The Investigation
After conducting some internet-based investigation, I found discovered I was not the only person seeing this, and an issue was already raised on GitHub under the Microsoft/WSL https://github.com/microsoft/WSL/issues/4288.
There are some great discussions around the subject on here, but for anyone who wants to know the resolution that worked for me, keep reading.
The Resolution
After trying a few different suggestions, the best resolution I have found is listed by jonaskuke.
Essentially, we needed to set Forwarding to be enabled across the two v-Switches. Using this command (with admin rights) based on my v-Switch names works.
There are some discussions around post reboot persistency as it appears the setting is discarded post reboot, which may be due to the WSL v-Switch taking a while to imitate. However, keep this command in a .ps1 file and all is good.