Install minikube with podman and CRI-O on wsl2 / Windows 11
Tags: tutorial, minikube, podman, kubernetes
Published: 2022-07-05 01:09:14

## 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](https://github.com/nullpo-head/wsl-distrod) tool to install WSL that has extra features like systemd, auto-start and port forwarding ability.

####1. Download [Distrod](https://github.com/nullpo-head/wsl-distrod/releases) zip file from the release page.
####2. Extract the file and just double click to run the tool
![Distrod](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03g5byctn7nynziyndo8.jpg)
####3. Select `[2] Download an image from linuxcontainers.org`
![Distrod Linux distro list.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5xt2oloyzhcp3vv4h4wg.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc7k4lqaxg9u9y4n6go1.jpg)

## Install minikube, podman and CRI-O 

####4. Install podman:
```shell
sudo dnf -y install podman
```
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

```shell
sudo dnf module enable cri-o:1.24
sudo dnf install cri-o
```


####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:

```shell
sudo dnf install containernetworking-plugins
```

####6. Install minikube

first install downloading tool wget:
```shell
sudo dnf install wget
```
Then Download Minikube binary:
```shell
sudo wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O /usr/local/bin/minikube
```

Finally, make it executable:

```shell
sudo chmod 0755 /usr/local/bin/minikube
```


####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
```shell
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
```

Then install kubectl :
```shell
sudo dnf install kubectl -y
```

####7. Start CRI-O service
This may not work in official Microsoft WSL distro (because of systemctl  support)
first, it is recommended to reboot 
```shell
sudo reboot
```

close the terminal and open again and enable the systemctl 

```shell
sudo systemctl daemon-reload
sudo systemctl enable crio --now
```
check with this command `sudo systemctl status crio`
should give no error, something like :
```shell
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
```

####8. Adding Podman to sudoers 
install nano:
```shell
sudo dnf install nano -y
```
then edit the sudoers file:
```shell
sudo nano /etc/sudoers
```
Append the following to the section at the very bottom of the file where username is your user account.

```yaml
myuser ALL=(ALL) NOPASSWD: /usr/bin/podman
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r9q22h67x1qphdirb4gx.jpg)
Be sure this text is after `#includedir /etc/sudoers.d`. To confirm it worked, try:
```shell
sudo -k -n podman version
```
####8. Starting minikube:
it is better to download the image before starting the cluster.
```shell
minikube start --driver=podman --container-runtime=cri-o --download-only=true
```
Then
```shell
minikube start --driver=podman --container-runtime=cri-o
```

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

minikube start --driver=podman

minikube delete

minikube start --driver=podman --container-runtime=cri-o
```


That's it, Kubernetes will be working now