Saturday, January 30, 2021

Cloud Ready Containers with WSL2

RedHat OpenShift is a popular, enhanced and extended version of Kubernetes. Available on numerous platforms, also locally as Cloud Ready Containers (CRC).

Have been fighting a bit to get the combination of CRC with WSL2 working on my Windows machine. Wasn't able to reach the OpenShift cluster form my WSL2 Linux machines.

Big thanks to colleague Stefaan De Geyter of sister company FlowFactor for hinting me the Set-NetIPInterface command. The Set-NetIPInterface -Forwarding Enabled command allows WSL2 to interact with the CRC VM.

Execute the below commands from PowerShell as Administrator:

Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled

Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)'} | Set-NetIPInterface -Forwarding Enabled

To double check that forwarding is enabled:

Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table

One drawback: after wake-up or reboot, need to enable forwarding again, a known issue.

As such one can install the OpenShift command line tools on WSL2 Linux instances and happily "oc" against the the local CRC cluster.