On the guide below, we will focus on how to run Minikube Kubernetes on Centos 9|AlmaLinux 9|RHEL 9. Kubernetes is an orchestration tool that is used to run containerized applications. It is a set of nodes that are machines that can be physical or virtual. These sets of nodes are known as the Kubernetes cluster which comprises Master nodes and Worker nodes. This cluster is applicable in production environments that require lots of machines. So in a case where you want to test Kubernetes locally or you are a new user trying out Kubernetes, this is where Minikube comes in.

Minikube is a utility that runs the Kubernetes cluster locally. It runs a single node of the Kubernetes cluster comprising both the Master and the Worker node components on a single node to carry out day-to-day testing operations. You can run it inside a VM on your laptop to try it out for daily development work.

With Minikube you get the following set of features:

  • Supports Load Balancing using the minikube tunnel.
  • Provides Addons for developers to share configurations.
  • Supports multi-cluster using minikube start.
  • Supports persistent volumes of files stored under specific directories like /var/lib/minikube.
  • Allows users to persistently store new default values to be used across all profiles using the Minikube config command.
  • Minikube has integrated support for the Kubernetes Dashboard UI.
  • Can access the internet via HTTP, HTTPS, and DNS protocols.

Run Minikube on Centos 9|AlmaLinux 9|RHEL 9

Minikube requires your system to be running on a virtual machine environment or a docker container. I will use the KVM hypervisor for this guide. In the case you do not have KVM, you can check the detailed installation guide on How To Install KVM on CentOS 9|AlmaLinux 9|RHEL 9. This guide will show you how to Run Kubernetes using Minikube on Centos 9|AlmaLinux 9|RHEL 9 systems.

1. Install KVM Hypervisor

Update your system packages

sudo dnf update -y

Install KVM and its dependencies with the following command

sudo dnf install -y qemu-kvm qemu-img libvirt virt-install libvirt-client

Enable and start the libvirtd service

sudo systemctl enable --now libvirtd

Check for the libvirtd service status

$ sudo systemctl status libvirtd
 libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor >
     Active: active (running) since Tue 2022-09-06 23:55:55 EAT; 9s ago
TriggeredBy: ● libvirtd-ro.socket
             ○ libvirtd-tls.socket
             ○ libvirtd-tcp.socket
             ● libvirtd-admin.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 5474 (libvirtd)
      Tasks: 21 (limit: 32768)
     Memory: 16.3M
        CPU: 303ms
     CGroup: /system.slice/libvirtd.service
             ├─5474 /usr/sbin/libvirtd --timeout 120
             ├─5586 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>
             └─5587 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>

Add your user to the libvirt group.

sudo usermod -a -G libvirt $(whoami)
newgrp libvirt

Edit the main configuration file

sudo vi /etc/libvirt/libvirtd.conf

Set the UNIX domain socket group ownership to libvirt by uncommenting the following line. In other words, remove the #.

unix_sock_group = "libvirt"

Set the UNIX socket permissions for the R/W socket by uncommenting the following line and setting the correct permissions.

unix_sock_rw_perms = "0770"

Save the file and restart the Libvirtd service.

sudo systemctl restart libvirtd

2. Install minikube on Centos 9|AlmaLinux 9|RHEL 9

Download the latest release of Minikube from the Github Latest releases page and install it.
Alternatively, you can install Minikube using the following command.

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Check for the Minikube version to confirm successful installation.

$ minikube version
minikube version: v1.26.1
commit: 62e108c3dfdec8029a890ad6d8ef96b6461426dc

3. Configure kubectl

Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. It can be used to deploy applications, inspect, and manage cluster resources.

3.1 Use kubectl with Minikube

In Minikube, kubectl is already configured to access the Kubernetes cluster when the minukube start command is executed. If it is not installed locally, you can use it as follows.

minikube kubectl -- <kubectl commands>

To avoid using the long command, configure it using one of the following methods.

## create an alias ##
alias kubectl="minikube kubectl --"

## create a symbolic link ##
ln -s $(which minikube) /usr/local/bin/kubectl

Confirm its availability by checking the version.

$ kubectl version --client -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "24",
    "gitVersion": "v1.24.3",
    "gitCommit": "aef86a93758dc3cb2c658dd9657ab4ad4afc21cb",
    "gitTreeState": "clean",
    "buildDate": "2022-07-13T14:30:46Z",
    "goVersion": "go1.18.3",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "kustomizeVersion": "v4.5.4"
}

3.2 Install kubectl Locally

If you prefer installing kubectl locally use the following command to download it.

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

Make the file executable.

chmod +x ./kubectl

Move it to a directory that is on $PATH.

sudo mv ./kubectl /usr/local/bin/kubectl

Confirm successful installation by checking the version.

$ kubectl version --client -o json
[[email protected] ~]$ kubectl version --client -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "24",
    "gitVersion": "v1.24.3",
    "gitCommit": "aef86a93758dc3cb2c658dd9657ab4ad4afc21cb",
    "gitTreeState": "clean",
    "buildDate": "2022-07-13T14:30:46Z",
    "goVersion": "go1.18.3",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "kustomizeVersion": "v4.5.4"
}

4. Start minikube

To start using Minikube as a single node cluster, run the following command

$ minikube start
😄  minikube v1.26.1 on Redhat 9.0 (kvm/amd64)
✨  Automatically selected the kvm2 driver. Other choices: podman, none, ssh
💾  Downloading driver docker-machine-driver-kvm2:
    > docker-machine-driver-kvm2-...:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > docker-machine-driver-kvm2-...:  11.86 MiB / 11.86 MiB  100.00% 24.47 MiB
💿  Downloading VM boot image ...
    > minikube-v1.26.1-amd64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.26.1-amd64.iso:  270.83 MiB / 270.83 MiB  100.00% 119.31 MiB 
👍  Starting control plane node minikube in cluster minikube
💾  Downloading Kubernetes v1.24.3 preload ...
    > preloaded-images-k8s-v18-v1...:  405.75 MiB / 405.75 MiB  100.00% 98.94 M
🔥  Creating kvm2 VM (CPUs=2, Memory=2200MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.24.3 on Docker 20.10.17 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

It will automatically pick the kvm2 driver. To use a specific driver like podman, you will have to use the following command when starting Minikube.

minikube start --driver=podman

Check the Minikube status with the following command.

$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

5. Deploy Applications

Create a deployment inside a Kubernetes cluster.

$ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
deployment.apps/hello-minikube created

Expose the service as a NodePort.

$ kubectl expose deployment hello-minikube --type=NodePort --port=8080
 service/hello-minikube exposed

To open the exposed endpoint on your browser, use the following command. It will then open on a browser.

$ minikube service hello-minikube
|-----------|----------------|-------------|-----------------------------|
| NAMESPACE |      NAME      | TARGET PORT |             URL             |
|-----------|----------------|-------------|-----------------------------|
| default   | hello-minikube |        8080 | http://192.168.39.212:31188 |
|-----------|----------------|-------------|-----------------------------|
🎉  Opening service default/hello-minikube in default browser...

The Browser opens as shown below

To upgrade your cluster, run the following command.

$ minikube start --kubernetes-version=latest
😄  minikube v1.26.1 on Redhat 9.0 (kvm/amd64)
✨  Using the kvm2 driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🏃  Updating the running kvm2 "minikube" VM ...
🐳  Preparing Kubernetes v1.24.3 on Docker 20.10.17 ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

6. Access dashboard

To access a Kubernetes dashboard, use the following command. This opens the dashboard on a browser.

minikube dashboard
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening http://127.0.0.1:39821/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

The browser will open the dashboard as shown below.

Use Ctrl + C to exit the process. If you do not want to open the browser and just get the URL, use the following command.

$ minikube dashboard --url
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
http://127.0.0.1:36755/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy

Use Ctrl + C to exit the process.

7. Enabling Addons

To list the available addons of your Minikube version, use the following command. This will list the addons’ names and their profile together with their status (enabled or disabled) and their maintainer.

$ minikube addons list
|-----------------------------|----------|--------------|--------------------------------|
|         ADDON NAME          | PROFILE  |    STATUS    |           MAINTAINER           |
|-----------------------------|----------|--------------|--------------------------------|
| ambassador                  | minikube | disabled     | 3rd party (Ambassador)         |
| auto-pause                  | minikube | disabled     | Google                         |
| csi-hostpath-driver         | minikube | disabled     | Kubernetes                     |
| dashboard                   | minikube | enabled ✅   | Kubernetes                     |
| default-storageclass        | minikube | enabled ✅   | Kubernetes                     |
| efk                         | minikube | disabled     | 3rd party (Elastic)            |
| freshpod                    | minikube | disabled     | Google                         |
| gcp-auth                    | minikube | disabled     | Google                         |
| gvisor                      | minikube | disabled     | Google                         |
| headlamp                    | minikube | disabled     | 3rd party (kinvolk.io)         |
| helm-tiller                 | minikube | disabled     | 3rd party (Helm)               |
| inaccel                     | minikube | disabled     | 3rd party (InAccel             |
|                             |          |              | [[email protected]])            |
| ingress                     | minikube | disabled     | Kubernetes                     |
| ingress-dns                 | minikube | disabled     | Google                         |
| istio                       | minikube | disabled     | 3rd party (Istio)              |
| istio-provisioner           | minikube | disabled     | 3rd party (Istio)              |
| kong                        | minikube | disabled     | 3rd party (Kong HQ)            |
| kubevirt                    | minikube | disabled     | 3rd party (KubeVirt)           |
| logviewer                   | minikube | disabled     | 3rd party (unknown)            |
| metallb                     | minikube | disabled     | 3rd party (MetalLB)            |
| metrics-server              | minikube | disabled     | Kubernetes                     |
| nvidia-driver-installer     | minikube | disabled     | Google                         |
| nvidia-gpu-device-plugin    | minikube | disabled     | 3rd party (Nvidia)             |
| olm                         | minikube | disabled     | 3rd party (Operator Framework) |
| pod-security-policy         | minikube | disabled     | 3rd party (unknown)            |
| portainer                   | minikube | disabled     | 3rd party (Portainer.io)       |
| registry                    | minikube | disabled     | Google                         |
| registry-aliases            | minikube | disabled     | 3rd party (unknown)            |
| registry-creds              | minikube | disabled     | 3rd party (UPMC Enterprises)   |
| storage-provisioner         | minikube | enabled ✅   | Google                         |
| storage-provisioner-gluster | minikube | disabled     | 3rd party (Gluster)            |
| volumesnapshots             | minikube | disabled     | Kubernetes                     |
|-----------------------------|----------|--------------|--------------------------------|

To enable an add-on, use the following syntax.

minikube addons enable <name>

For an addon that exposes a browser endpoint, you can quickly open with:

$ minikube addons open <name>

To disable an addon.

$ minikube addons disable <name>

8. Manage your Cluster

To pause your cluster:

$ minikube pause

To resume your paused cluster:

$ minikube unpause

To stop a cluster:

$ minikube stop

To increase memory default:

$ minikube config set memory 16384

To create a second cluster:

$ minikube start -p aged --kubernetes-version=v1.16.1

Delete all clusters:

$ minikube delete --all

You can choose whether emoji should appear on minikube or not. Set its style to 0 or false to disable and 1 or true to enable.

export MINIKUBE_IN_STYLE=false

9. Uninstall minikube Kubernetes on Centos 9|AlmaLinux 9|RHEL 9

To uninstall minikube, stop the service.

$ minikube stop
* Stopping node "minikube"  ...
* 1 node stopped.

Then run the following command to remove the minikube VM and any traces of minikube clusters.

$ minikube delete
* Deleting "minikube" in kvm2 ...
* Removed all traces of the "minikube" cluster.

Then manually remove the configuration files with the following command

$ sudo rm /usr/local/bin/minikube

Conclusion

Minikube is a utility tool that enables us to run Kubernetes clusters locally on our systems for day-to-day testing and development operations. This guide has shown you how to run Kubernetes using Minikube on Centos 9|AlmaLinux 9|RHEL 9 systems. We have also seen how to enable add-ons and access the Kubernetes dashboard UI. For more articles, check below;

LEAVE A REPLY

Please enter your comment!
Please enter your name here