DEV Community 👩‍💻👨‍💻

Cover image for Install minikube with podman and CRI-O on wsl2 / Windows 11
msh2050
msh2050

Posted on

Install minikube with podman and CRI-O on wsl2 / Windows 11

What is minikube

There are various solutions that can deploy Kubernetes on your development machine, minikube as it is advertised on their site quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows.
The easy setup can be done if you want the standard method using virtual machine or docker, but if you want to try the newcomers podman and CRI-O it will be tricky and may not work as it is experimental.
In this tutorial, I will share the steps that I make it working in a successful and easy way.

Install WSL distro

I used Distrod tool to install WSL that has extra features like systemd, auto-start and port forwarding ability.

1. Download Distrod zip file from the release page.

2. Extract the file and just double click to run the tool

Distrod

3. Select [2] Download an image from linuxcontainers.org

Distrod Linux distro list.

I tried Ubuntu, but it is not easy to get the latest build, and it needs adding repos … the steps will be doubled and may not work.
So I used fedora, the podman and CRI-O will be easy to install with the most resent released edition.

3. Select [11] fedora then install edition 36 [1] 36

fedora username and password

Install minikube, podman and CRI-O

4. Install podman:

sudo dnf -y install podman
Enter fullscreen mode Exit fullscreen mode

As of today this will install podman version 4.1.1 which is the newest edition like you build it from source…

5. Install CRI-O:

as you can see below it is easy to install CRI-O by setting the version to be installed after : as of today the latest version is 1.24

sudo dnf module enable cri-o:1.24
sudo dnf install cri-o
Enter fullscreen mode Exit fullscreen mode

5. Install containernetworking-plugins package

Note: as of 1.24.0, the cri-o package no longer depends on containernetworking-plugins package. Removing this dependency allows users to install their own CNI plugins without having to remove files first. If users want to use the previously provided CNI plugins, they should also run:

sudo dnf install containernetworking-plugins
Enter fullscreen mode Exit fullscreen mode

6. Install minikube

first install downloading tool wget:

sudo dnf install wget
Enter fullscreen mode Exit fullscreen mode

Then Download Minikube binary:

sudo wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O /usr/local/bin/minikube
Enter fullscreen mode Exit fullscreen mode

Finally, make it executable:

sudo chmod 0755 /usr/local/bin/minikube
Enter fullscreen mode Exit fullscreen mode

6. Install kubectl (optional)

minikube has it its own kubectl, but you may like using the stand alone one

I recommend installing with native package management

First add the repo

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
Enter fullscreen mode Exit fullscreen mode

Then install kubectl :

sudo dnf install kubectl -y
Enter fullscreen mode Exit fullscreen mode

7. Start CRI-O service

This may not work in official Microsoft WSL distro (because of systemctl support)
first, it is recommended to reboot

sudo reboot
Enter fullscreen mode Exit fullscreen mode

close the terminal and open again and enable the systemctl

sudo systemctl daemon-reload
sudo systemctl enable crio --now
Enter fullscreen mode Exit fullscreen mode

check with this command sudo systemctl status crio
should give no error, something like :

crio.service - Container Runtime Interface for OCI (CRI-O)
     Loaded: loaded (/usr/lib/systemd/system/crio.service; enabl
ed; vendor preset: disabled)
     Active: active (running) since Sun 2022-07-03 22:26:54 +03; 4min 46s ago
       Docs: https://github.com/cri-o/cri-o
   Main PID: 208 (crio)
      Tasks: 11
     Memory: 30.6M
     CGroup: /system.slice/crio.service
             └─ 208 /usr/bin/crio
Enter fullscreen mode Exit fullscreen mode

8. Adding Podman to sudoers

install nano:

sudo dnf install nano -y
Enter fullscreen mode Exit fullscreen mode

then edit the sudoers file:

sudo nano /etc/sudoers
Enter fullscreen mode Exit fullscreen mode

Append the following to the section at the very bottom of the file where username is your user account.

myuser ALL=(ALL) NOPASSWD: /usr/bin/podman
Enter fullscreen mode Exit fullscreen mode

Image description
Be sure this text is after #includedir /etc/sudoers.d. To confirm it worked, try:

sudo -k -n podman version
Enter fullscreen mode Exit fullscreen mode

8. Starting minikube:

it is better to download the image before starting the cluster.

minikube start --driver=podman --container-runtime=cri-o --download-only=true
Enter fullscreen mode Exit fullscreen mode

Then

minikube start --driver=podman --container-runtime=cri-o
Enter fullscreen mode Exit fullscreen mode

If it fails from the first time delete and try again without container runtime option then delete and try…

minikube delete

minikube start --driver=podman

minikube delete

minikube start --driver=podman --container-runtime=cri-o
Enter fullscreen mode Exit fullscreen mode

That's it, Kubernetes will be working now

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.