Kubernetes Setup with Minikube on WSL2 [2024]
![Kubernetes Setup with Minikube on WSL2 [2024]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1719215573090%2Fcbf2510b-49ff-49df-8519-3baa333e7df7.png&w=3840&q=75)
Aspiring DevOps | Web Developer | Containerisation | myselfMohammedaArif | Graduate '19-'23
I wanted to learned Kubernetes but installing it seemed more difficult than actually learning especially in WSL2. So, let’s see an updated and easy way to set it up.
The great thing about this approach is that we’ll not install Docker Desktop, instead we’ll install Docker inside WSL2 which won’t interfere with other WSL2 Images.
What you’ll need?
Ubuntu
Good Internet Speed
Let’s install Ubuntu from Microsoft Store (I’m assuming you’ve already installed WSL2 on your system).

After installing, setup Ubuntu by creating username and password in the first-time setup.
Now, follow these steps:
Enable systemd in WSL2.
$ sudo nano /etc/wsl.conf
Add following lines in it and save.
[boot]
systemd=true
Shutdown wsl2 and start it again.
$ wsl --shutdown
$ wsl
Installing Docker
$ sudo apt update && sudo apt upgrade -y
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update -y
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER && newgrp docker
Install Minikube
# Download the latest Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# Make it executable
chmod +x ./minikube
# Move it to your user's executable PATH
sudo mv ./minikube /usr/local/bin/
#Set the driver version to Docker
minikube config set driver docker
Install Kubectl
# Download the latest Kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Make it executable
chmod +x ./kubectl
# Move it to your user's executable PATH
sudo mv ./kubectl /usr/local/bin/
Running Minikube
$ minikube start
It will take couple of minutes depending upon your internet connection.

If it shows you an error, it could be possible to your WSL2 is out of date as systemd was introduced in Sept-2022.
To fix that
# In powershell type wsl.exe — update and try running minikube start after restarting wsl
Once your minikube starts working, type:
$ kubectl config use-context minikube
# Start minikube again to enable kubectl in it
$ minikube start
$ kubectl get pods -A

You’ll see something.
You have successfully installed and configured Kubernetes on localsystem using WSL2.


