site/content/docs/user/using-wsl2.md
Download the latest ISO at https://www.microsoft.com/en-us/software-download/. Choose the latest Windows 10 or Windows 11 release.
Required Settings
Set-VMProcessor -VMName ... -ExposeVirtualizationExtensions $trueNow, start up the VM. Watch carefully for the "Press any key to continue installation..." screen so you don't miss it. Windows Setup will start automatically.
If you're using a physical machine, you can mount the ISO, copy the files to a FAT32 formatted USB disk, and boot from that instead. Be sure the machine is configured to boot using UEFI (not legacy BIOS), and has Intel VT or AMD-V enabled for the hypervisor.
If you want the full details, see the Installation Instructions for WSL2. This is the TL;DR version.
Once your Windows machine is ready, you need to do a few more steps to set up WSL2
Open a PowerShell window as an admin, then run
{{< codeFromInline lang="powershell" >}} Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform, Microsoft-Windows-Subsystem-Linux {{< /codeFromInline >}}
Reboot when prompted.
After the reboot, set WSL to default to WSL2. Open an admin PowerShell window and run {{< codeFromInline lang="powershell" >}} wsl --set-default-version 2 {{< /codeFromInline >}}
Now, you can install your Linux distro of choice by searching the Windows Store. If you don't want to use the Windows Store, then follow the steps in the WSL docs for manual install.
Start up your distro with the shortcut added to the start menu
Install Docker with WSL2 backend here: https://docs.docker.com/docker-for-windows/wsl/
Alternatively, docker can be installed in WSL2 without using Docker Desktop. See for example: https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9
Now, move on to the Quick Start to set up your cluster with kind.
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes:
kind create cluster --config=cluster-config.ymlkubectl create deployment nginx --image=nginx --port=80kubectl create service nodeport nginx --tcp=80:80 --node-port=30000curl localhost:30000Alternatively, see Helpful Tips for WSL2
If you want to create a Kubernetes Service with sessionAffinity: ClientIP it will not be accessible (and neither will any Service created afterwards).
WSL2 kernel is missing xt_recent kernel module, which is used by Kube Proxy to implement session affinity. You need to compile a custom kernel to enable this feature.
xt_recent kernel module enabled
{{< codeFromInline lang="bash" >}}
docker run --name wsl-kernel-builder --rm -it ubuntu:latest bashWSL_COMMIT_REF=linux-msft-wsl-6.6.87.2-1 # change this line to the version you want to build
apt update apt install -y git build-essential flex bison libssl-dev libelf-dev bc dwarves python3 cpio
mkdir src cd src git init git remote add origin https://github.com/microsoft/WSL2-Linux-Kernel.git git config --local gc.auto 0 git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +${WSL_COMMIT_REF}:refs/remotes/origin/build/linux-msft-wsl-5.15.y git checkout --progress --force -B build/linux-msft-wsl-5.15.y refs/remotes/origin/build/linux-msft-wsl-5.15.y
sed -i 's/# CONFIG_NETFILTER_XT_MATCH_RECENT is not set/CONFIG_NETFILTER_XT_MATCH_RECENT=y/' Microsoft/config-wsl
make -j2 KCONFIG_CONFIG=Microsoft/config-wsl
docker cp wsl-kernel-builder:/src/arch/x86/boot/bzImage . {{< /codeFromInline >}}
Configure WSL to use newly built kernel: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig
Create a .wslconfig file in C:\Users\<your-user-name>\:
{{< codeFromInline lang="toml" >}}
[wsl2]
kernel=c:\path\to\your\kernel\bzImage
{{< /codeFromInline >}}
wsl --terminate <distro>. Closing a WSL2 window doesn't shut it down automatically.wsl --list --verbose.wsl --set-version <distro> 2kubectl port-forward --address=0.0.0.0.