kubectl: not found in WSL terminal

9/16/2021

I installed WSL2 on Windows10 followed these instructions: https://docs.microsoft.com/en-us/windows/wsl/install-win10, manual install.

All commands worked for me however at the end when I open wsl terminal and type kubectl I have response -sh: kubectl: not found.

I installed Ubuntu 20.04 LTS and when I open the Ubuntu terminal then kubectl works there.

Powershell says it's installed correctly:

PS C:\Users\michu> wsl --list --verbose
  NAME                   STATE           VERSION
 *docker-desktop         Running         2
  docker-desktop-data    Running         2
  Ubuntu-20.04           Running         2

How can I make docker/kubectl works in the WSL terminal as well?
Shouldn't it work right after all the instruction steps?

-- Michu93
docker
kubernetes
windows-10
windows-subsystem-for-linux

1 Answer

9/16/2021

The answer was in one of the comments, clarifying it so it will be useful to others as well

# run this command in order to enable kubectl in your wsl terminal
wsl --setdefault Ubuntu-20.04
-- CodeWizard
Source: StackOverflow