Kubernetes

Install Minikube on CentOS Stream 9 With KVM

Minikube supported features

Some of the features which you can run from Kubernetes running in Minikube are:

Original content from computingforgeeks.com - post 44388
  • DNS
  • NodePorts
  • ConfigMaps and Secrets
  • Dashboards
  • Container Runtime: Docker, CRI-O, and containerd
  • Enabling CNI (Container Network Interface)
  • Ingress
  • PersistentVolumes of type hostPath

Minikube supports both VirtualBox and KVM hypervisors., but this guide is for running Minikube on CentOS Stream Linux machine.

1. Install KVM Hypervisor

Run the following commands to update all system packages to the latest release:

sudo yum -y update

As stated earlier, we’ll use KVM as Hypervisor of choice for the Minikube VM. Install it as follows.

sudo dnf install -y libvirt qemu-kvm virt-install virt-top

Start and enable libvirtd service.

sudo systemctl enable --now libvirtd

Confirm that libvirtd service is running.

$ systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2024-01-20 14:33:07 EAT; 1s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
 Main PID: 20569 (libvirtd)
    Tasks: 20 (limit: 32768)
   Memory: 70.4M
   CGroup: /system.slice/libvirtd.service
           ├─ 2653 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           ├─ 2654 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           └─20569 /usr/sbin/libvirtd

Jan 20 14:33:07 cent8.localdomain systemd[1]: Starting Virtualization daemon...
Jan 20 14:33:07 cent8.localdomain systemd[1]: Started Virtualization daemon.
Jan 20 14:33:08 cent8.localdomain dnsmasq[2653]: read /etc/hosts - 2 addresses
Jan 20 14:33:08 cent8.localdomain dnsmasq[2653]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 20 14:33:08 cent8.localdomain dnsmasq-dhcp[2653]: read /var/lib/libvirt/dnsmasq/default.hostsfile

If not running after installation, then start and set it to start at boot.

sudo systemctl enable --now libvirtd

You user should be part of libvirt group.

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

Open the file /etc/libvirt/libvirtd.conf for editing.

sudo vi /etc/libvirt/libvirtd.conf

Set the UNIX domain socket group ownership to libvirt, (around line 85)

unix_sock_group = "libvirt"

Set the UNIX socket permissions for the R/W socket (around line 102)

unix_sock_rw_perms = "0770"

Restart libvirt daemon after making the change.

sudo systemctl restart libvirtd.service

2. Download and Configure Minikube

You need to download the minikube binary. I will put the binary under /usr/local/bin directory since it is inside $PATH.

sudo yum -y install wget
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube-linux-amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube

Confirm installation of Minikube on your system.

$ minikube version
minikube version: v1.33.1
commit: 5883c09216182566a63dff4c326a6fc9ed2982ff

We need kubectl which is a command-line tool used to deploy and manage applications on Kubernetes.

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

Give the file executable bit and move to a location in your PATH.

chmod +x kubectl
sudo mv kubectl  /usr/local/bin/

Confirm the version of kubectl installed.

$ kubectl version --client -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "30",
    "gitVersion": "v1.30.2",
    "gitCommit": "39683505b630ff2121012f3c5b16215a1449d5ed",
    "gitTreeState": "clean",
    "buildDate": "2024-06-11T20:29:44Z",
    "goVersion": "go1.22.4",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "kustomizeVersion": "v5.0.4-0.20230601165947-6ce0bf390ce3"
}

Now that components are installed, you can start minikube. VM image will be downloaded and configured for Kubernetes single node cluster.

Edit Libvirtd configuration file and set group:

$ sudo vim /etc/libvirt/libvirtd.conf
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"

Restart libvirtd daemon:

sudo systemctl restart libvirtd

Add your username to libvirt group:

sudo usermod -aG libvirt $USER
newgrp libvirt

Confirm your user account is part of the group.

$ id
uid=1000(jkmutai) gid=989(libvirt) groups=989(libvirt),10(wheel),1000(jkmutai)

For a list of options, run:

minikube start --help

To create a minikube VM with the default options, run:

minikube start

The default container runtime to be used is docker, but you can also use crio or containerd:

minikube start --container-runtime=cri-o
minikube start --container-runtime=containerd

The installer will automatically detect KVM and download KVM driver.

If you have more than one hypervisor, then specify it.

minikube start --vm-driver kvm2

Please note that latest stable release of Kubernetes is installed. Use --kubernetes-version flag to specify version to be installed. Example:

--kubernetes-version='<VERSION>'

Wait for the download and setup to finish then confirm that everything is working fine.

$ minikube start
.....
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

3. Minikube Basic operations

The kubectl command line tool is configured to use “minikube“.

To check cluster status, run:

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

$ kubectl cluster-info
Kubernetes master is running at https://192.168.39.2:8443
KubeDNS is running at https://192.168.39.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Your Minikube configuration file is located under ~/.minikube/machines/minikube/config.json

To View Config, use:

kubectl config view

To check running nodes:

$ kubectl get nodes
NAME       STATUS   ROLES                  AGE     VERSION
minikube   Ready    control-plane,master   2m53s   v1.24.6

Access minikube VM using ssh:

$ minikube ssh

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

$ sudo su -
# cat /etc/os-release
NAME=Buildroot
VERSION=2021.02.4-dirty
ID=buildroot
VERSION_ID=2021.02.4
PRETTY_NAME="Buildroot 2021.02.4"
# exit
logout
$ exit
logout

To stop a running local kubernetes cluster, run:

$ minikube stop
* Stopping "minikube" in kvm2 ...
* "minikube" stopped.

To start VM, run:

minikube start

To delete a local kubernetes cluster, use:

minikube delete

4. Enable Kubernetes Dashboard

Kubernetes ships with a web dashboard which allows you to manage your cluster without interacting with a command line. The dashboard addon is installed and enabled by default on minikube.

$ minikube addons list
|-----------------------------|----------|--------------|-----------------------|
|         ADDON NAME          | PROFILE  |    STATUS    |      MAINTAINER       |
|-----------------------------|----------|--------------|-----------------------|
| ambassador                  | minikube | disabled     | unknown (third-party) |
| auto-pause                  | minikube | disabled     | google                |
| csi-hostpath-driver         | minikube | disabled     | kubernetes            |
| dashboard                   | minikube | disabled     | kubernetes            |
| default-storageclass        | minikube | enabled ✅   | kubernetes            |
| efk                         | minikube | disabled     | unknown (third-party) |
| freshpod                    | minikube | disabled     | google                |
| gcp-auth                    | minikube | disabled     | google                |
| gvisor                      | minikube | disabled     | google                |
| helm-tiller                 | minikube | disabled     | unknown (third-party) |
| ingress                     | minikube | disabled     | unknown (third-party) |
| ingress-dns                 | minikube | disabled     | unknown (third-party) |
| istio                       | minikube | disabled     | unknown (third-party) |
| istio-provisioner           | minikube | disabled     | unknown (third-party) |
| kubevirt                    | minikube | disabled     | unknown (third-party) |
| logviewer                   | minikube | disabled     | google                |
| metallb                     | minikube | disabled     | unknown (third-party) |
| metrics-server              | minikube | disabled     | kubernetes            |
| nvidia-driver-installer     | minikube | disabled     | google                |
| nvidia-gpu-device-plugin    | minikube | disabled     | unknown (third-party) |
| olm                         | minikube | disabled     | unknown (third-party) |
| pod-security-policy         | minikube | disabled     | unknown (third-party) |
| portainer                   | minikube | disabled     | portainer.io          |
| registry                    | minikube | disabled     | google                |
| registry-aliases            | minikube | disabled     | unknown (third-party) |
| registry-creds              | minikube | disabled     | unknown (third-party) |
| storage-provisioner         | minikube | enabled ✅   | kubernetes            |
| storage-provisioner-gluster | minikube | disabled     | unknown (third-party) |
| volumesnapshots             | minikube | disabled     | kubernetes            |
|-----------------------------|----------|--------------|-----------------------|

Enabling plugins:

minikube addons enable <plugin-name>

Example:

minikube addons enable csi-hostpath-driver

To open directly on your default browser, use:

 minikube dashboard

To get the URL of the dashboard

$ minikube dashboard --url
http://192.168.39.117:30000

Access Kubernetes Dashboard by opening the URL on your favorite browser. For further reading, check:

More guides on Kubernetes:

Related Articles

CentOS Installation of MariaDB 10.6 on CentOS 7 | CentOS 8 Containers Teleport – Secure Access to Linux Systems and Kubernetes Kubernetes Easily Setup EKS Kubernetes Cluster on AWS CentOS How To Install Zextras Suite on Zimbra CentOS 7

Leave a Comment

Press ESC to close