Install Minikube Rocky Linux 9 and Create Kubernetes Cluster

Posted on 272 views

kubernetes is one of the technologies that have immensely been adopted by organizations in the past years. This is due to the fact that it allows organizations to build and modernize their applications for the cloud.

Kubernetes is an open-source orchestration tool that plays a big role in running containerized workloads across a cluster of hosts. This is achieved by distributing the workloads across the cluster and automating the container networking needs.

There are several tools that can be used to create a Kubernetes cluster on Linux. Among the most preferred tools is Minikube. This is an open-source virtual machine-based tool that provides the easiest and most effective way to get started with Kubernetes. It helps one to quickly set up a single-node Kubernetes cluster on their home workstation. Minikube can help one get familiar with and practice Kubernetes concepts without struggling. It provides a command-line-based as well as a web UI where you can run cluster operations such as starting, stopping, and deleting nodes from the Cluster e.t.c.

The features of Minikube include:

  • It runs on Windows, Linux, and macOS.
  • It supports the latest Kubernetes release
  • It supports multiple container runtimes i.e Containerd, KVM, Docker, Podman e.t.c
  • It has supports for advanced features such as Load balancing, Featuregates, and filesystems mounts.
  • Ingress- API with rules that dictates access to services in a cluster.
  • NodePorts and DNS
  • ConfigMaps and Secrets

This guide aims to help you install Minikube Rocky Linux 9 and create a Kubernetes cluster.

Setup Pre-requisites

To be able to run Kubernetes using Minikube, you need a system that meets the below specifications:

  • 2 CPUs or more
  • Minimum 2GB of Physical Memory (RAM).
  • 20GB of Disk Space.
  • Container or virtual machine manager such as Docker, KVM, Podman, Virtual Box e.t.c.
  • Internet connection.

#1. Install KVM / VirtualBox Hypervisor on Rocky Linux 9

As stated earlier, Minikube supports a number of Container or virtual machine managers. In this guide, we will be using KVM / VirtualBox.

Using Minikube with KVM Hypervisor

Install KVM on Rocky Linux using the aid of the guide below:

Validate the installation:

$ lsmod | grep kvm
kvm_intel             364544  0
kvm                  1056768  1 kvm_intel
irqbypass              16384  1 kvm

Also, validate that libvirt reports no errors:

$ virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS

Add the system user to the KVM group in order to execute commands without sudo

sudo usermod -aG libvirt $USER
newgrp libvirt

Using Minikube with VirtualBox Hypervisor

Install VirtualBox on Rocky Linux 9 using the aid of the guide below:

Ensure Nested virtualization is enabled on your system.

#2. Install kubectl on Rocky Linux 9

kubectl provides an easy way you manage the Kubernetes cluster. It can be installed on Rocky Linux 9 using the command:

curl -LO`curl -s`/bin/linux/amd64/kubectl

Make the file executable:

chmod +x kubectl

More the file to your $PATH:

sudo mv kubectl /usr/local/bin/

Validate the installation.

$ kubectl version --client -o json

    "major": "1",
    "minor": "25",
    "gitVersion": "v1.25.0",
    "gitCommit": "a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2",
    "gitTreeState": "clean",
    "buildDate": "2022-08-23T17:44:59Z",
    "goVersion": "go1.19",
    "compiler": "gc",
    "platform": "linux/amd64"
  "kustomizeVersion": "v4.5.7"

#3. Install Minikube on Rocky Linux 9

Once the container or virtual machine manager has been installed, Minikube can be installed on Rocky Linux 9. First, download the Minikube package:

wget -O minikube

Also, download the required Docker drivers for KVM


Make the files executable:

chmod +x minikube docker-machine-driver-kvm2

Move the files to your $PATH:

sudo cp minikube docker-machine-driver-kvm2 /usr/local/bin/

Verify Minikube installation on Rocky Linux 9:

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

#4. Run Kubernetes on Minikube

Now Minikube Kubernetes can be started by specifying the driver to be used:

# With VirtualBox Driver
minikube start --driver=virtualbox

# With KVM2 Driver
minikube start --driver=kvm2

Alternatively, you can set the default driver and then start Minikube as shown:

# Set VirtualBox as default driver
minikube config set driver virtualbox
minikube start

# Set KVM as default driver
minikube config set driver kvm2
minikube start

Execution output:


From the above output, we can all agree that the virtual machine boot image has been downloaded and a Kubernetes cluster created using a single node. You can now check the status of Minikube:

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

You can also use kubectl to check the status of the nodes:

$ kubectl get nodes
NAME       STATUS   ROLES           AGE    VERSION
minikube   Ready    control-plane   2m8s   v1.24.3

The docker environment can be checked as shown:

$ minikube docker-env
export DOCKER_HOST="tcp://"
export DOCKER_CERT_PATH="/home/rocky9/.minikube/certs"

# To point your shell to minikube's docker-daemon, run:
# eval $(minikube -p minikube docker-env)

#5. Create Pods on Kubernetes using Minikube.

We will demonstrate this by creating Nginx deployment with the command:

$ kubectl create deployment webserver --image=nginx
deployment.apps/webserver created

Verify if the pod is running:

$ kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
webserver-566b9f9975-txllm   1/1     Running   0          39s

To access the pod shell, issue the command:

$ kubectl exec -ti webserver-566b9f9975-txllm -- /bin/bash
[email protected]:/# exit

#6. Deploy Kubernetes Services on Minikube

On Kubernetes, services allow pods to perform specific functions such as web services, image processing, and many others. They are also used to define policies for their access.

Kubernetes offers ClusterIP, NodePort, and LoadBalancer. services. These services can be deployed as shown:

NodePort Service

A NodePort service exposes a service using a static port on each node on the cluster. To deploy a NodePort service on our running Nginx pod, we will use the command below:

$ kubectl expose deployment webserver --type="NodePort" --port 80
service/webserver exposed

Obtain the port to which the service has been exposed:

$ kubectl get service webserver
NAME        TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
webserver   NodePort           80:32431/TCP   4s

To get all the environment information of the pod, use the command below replacing the pod name:

$ kubectl exec webserver-566b9f9975-txllm -- env

You can easily generate the URL for the created service using the command:

$ minikube service webserver --url

Verify if the service is accessible from your browser:


LoadBalancer Service

The LoadBalancer Service exposes the service by providing an IP address. But first, enable the MetalLB that makes it possible to set external Ip addresses.

minikube addons enable metallb

Once enabled, we need to set the IP range. Obtain the Minikube IP address.

$ minikube ip

Now set the IP range on the subnet above:

$ minikube addons configure metallb
-- Enter Load Balancer Start IP:
-- Enter Load Balancer End IP:
    ▪ Using image metallb/speaker:v0.9.6
    ▪ Using image metallb/controller:v0.9.6
✅  metallb was successfully configured

Now expose the service using LoadBalancer as shown:

$ kubectl expose deployment webserver  --type="LoadBalancer" --port 80 --target-port 80
service/webserver exposed

Verify the service:

$ kubectl get svc
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP                  443/TCP        6m19s
webserver    LoadBalancer   80:30072/TCP   6s

The service has now been exposed and can be accessed with the URL


#7. Enable Ingress on Minikube

An Ingress can also be used to define how external access to services in a cluster happen. An ingress controller satisfies the rules configured in the Ingress.

The Ingress controller can be enabled on Minikube with the command:

minikube addons enable ingress

To verify if the Ingress controller is running, execute the command:

$ kubectl get pods -n ingress-nginx
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-2n5z5        0/1     Completed   0          67s
ingress-nginx-admission-patch-6d55q         0/1     Completed   1          67s
ingress-nginx-controller-755dfbfc65-9sb7d   1/1     Running     0          67s

N0w create an Ingres to the service. For the demonstration, we will create an Ingress to the NodePort/Loadbalancer service running:

vim ingress.yaml

The file will contain the below lines:

kind: Ingress
  name: example-ingress
  annotations: /$1
    - host:
          - path: /
            pathType: Prefix
                name: webserver
                  number: 80

Apply the manifest:

kubectl create -f ingress.yaml

Verify the creation:

$ kubectl get ingress
NAME              CLASS   HOSTS                         ADDRESS   PORTS   AGE
example-ingress   nginx             80      4s

Obtain the Minikube IP address.

$ minikube ip

Now edit /etc/hosts and add the hostname and IP address provided above:

Now access the service via port 80 with the provided hostname:


#8. Scaling applications on Minikube

Kubernetes allows one to scale applications by creating replications to handle large traffic. This is mainly done to load balance requests. Minikube supports scaling of Kubernetes applications using the command:

$ kubectl scale deployment webserver --replicas=4
deployment.apps/webserver scaled

Verify the scaling:

$ kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
webserver-566b9f9975-kw6s8   1/1     Running   0          3m9s
webserver-566b9f9975-m5sbz   1/1     Running   0          9s
webserver-566b9f9975-p44lf   1/1     Running   0          9s
webserver-566b9f9975-xxbml   1/1     Running   0          9s

#9. Access the Minikube Dashboard.

Amongst the features provided by Minikube is the web dashboard that makes it easy to manage the Kubernetes cluster.

The web UI can be enabled by running the command:

$ minikube dashboard
🔌  Enabling dashboard ...
    ▪ Using image kubernetesui/metrics-scraper:v1.0.8
    ▪ Using image kubernetesui/dashboard:v2.6.0
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening in your default browser...

The dashboard will launch automatically on your browser.


From this dashboard, you will be able to do all the required configurations.

#10. Configure Persistent Volumes on Minikube

Minikube supports PersistentVolumes of type hostPath. The PVs are mapped to a directory in the Minikube VM. The files persist in the following directories:

  • /data
  • /var/lib/docker
  • /var/lib/containerd
  • /var/lib/buildkit
  • /var/lib/containers
  • /tmp/hostpath_pv*
  • /tmp/hostpath-provisioner*

By default, there is a Storage Class created. Verify this with the command:

$ kubectl get sc
standard (default)   Delete          Immediate           false                  10m

This storage class can be used to create PVs. For example, create a manifest for the PV with the command:

$ vim sample-pv.yml
apiVersion: v1
kind: PersistentVolume
  name: sample-pv
  storageClassName: standard
    - ReadWriteOnce
    storage: 5Gi
    path: /data/pv0001/

Create the volume with the command:

 kubectl create -f sample-pv.yml

Now create a Persistent Volume Claim from the created PV above:

$ vim sample-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
  name: my-pvc
  namespace: default
  #our storage class here
  storageClassName: standard
    - ReadWriteOnce
      storage: 5Gi

Apply the config:

kubectl create -f sample-pvc.yml

To create an application that uses the PVC, proceed as shown:

$ vim pod.yml
apiVersion: v1
kind: Pod
  name: task-pv-pod
    - name: task-pv-storage
        claimName: my-pvc
    - name: task-pv-container
      image: nginx
        - containerPort: 80
          name: "http-server"
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage

Apply the manifest:

kubectl create -f pod.yml

Verify if the PVC is bound:

$ kubectl get pvc
my-pvc   Bound    sample-pv   5Gi        RWO            standard       71s

$ kubectl get pv
sample-pv   5Gi        RWO            Retain           Bound    default/my-pvc   standard                3m

#11. Runtime configuration on Minikube

The Minikube runtime varies. But you can select the preferred runtime when starting Minikube.

For example:

minikube start --container-runtime=docker

The other supported runtimes are:

#12. Manage Minikube

Minikube can be managed as below:

To SSH into Minikube, use the command:

$ minikube ssh
                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)


To view all the Minikube add-ons use the command:

$ 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 | disabled     | Kubernetes                     |
| default-storageclass        | minikube | enabled ✅   | Kubernetes                     |
| 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 pause and unpause Minikube Kubernetes use the command:

$ minikube pause
⏸️  Pausing node minikube ... 

$ minikube unpause
⏸️  Unpausing node minikube ... 
⏸️  Unpaused 0 containers in: kube-system, kubernetes-dashboard, storage-gluster, istio-operator

To stop Minikube, use the command:

$ minikube stop
✋  Stopping node "minikube"  ...
🛑  1 node stopped.

To restart Minikube:

minikube start

To destroy the VM execute the command:

minikube delete

The end!


We have come to the end of this guide on how to install Minikube Rocky Linux 9 and create a Kubernetes cluster. I hope this was important to you.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.