Install Minikube Kubernetes on CentOS 8 / CentOS 7 using KVM

This tutorial was written to help you install Minikube on CentOS 8 / CentOS 7 using KVM Hypervisor. Minikube is an open source tool designed to allow developers and system administrators to boot a single-node Kubernetes cluster on a local computer (laptop, desktop workstation) in minutes. This is ideal for development and POC, but not for running production workloads.

To install Minikube on Ubuntu / Debian Linux systems, check: How to install Minikube on Ubuntu / Debian Linux. In short, Minikube packages and configures a Linux VM, and then installs Docker and all Kubernetes components into it. You can manage and deploy applications through kubectl running on the host system.

Kubernetes supported features

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

  • DNS
  • Node port
  • ConfigMap and secrets
  • Dashboard
  • Container runtime: Docker, CRI-Owith Boxed
  • Enable CNI (Container Network Interface)
  • Entrance
  • Persistent type hostPath

Minikube supports VirtualBox and KVM hypervisors. However, this guide is for running Minikube with KVM on CentOS 8 / CentOS 7 Linux machines.

Step 1: Update the system

Run the following command to update all system packages to the latest version:

sudo yum -y update

Step 2: Install the KVM hypervisor

As mentioned earlier, we will use KVM as the preferred Hypervisor for Minikube VM. This is our complete guide to installing KVM on CentOS / RHEL 8.

How to install KVM on RHEL 8 / CentOS 8 Linux

Install KVM on CentOS 7

Confirm that the 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 2020-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 it does not run after installation, start it and set it to start at startup.

sudo systemctl enable --now libvirtd

Your users should belong to 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 UNIX domain socket group ownership to libvirt (near line 1) 85)

unix_sock_group = "libvirt"

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

unix_sock_rw_perms = "0770"

After making changes, restart the libvirt daemon.

sudo systemctl restart libvirtd.service

Step 3: Download minikube

You need to download the minikube binary. I put the binary in the / usr / local / bin directory because 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 that Minikube is installed on the system.

$ minikube version
minikube version: v1.6.2
commit: 54f28ac5d3a815d1196cd5d57d707439ee4bb392

Step 4: Install kubectl

We need kubectl, a command line tool for deploying and managing 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

Bit the executable file and move it to a location in the PATH.

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

Confirm the version of kubectl installed.

$ kubectl version -o json
 {
   "clientVersion": {
     "major": "1",
     "minor": "17",
     "gitVersion": "v1.17.1",
     "gitCommit": "d224476cd0730baca2b6e357d144171ed74192d6",
     "gitTreeState": "clean",
     "buildDate": "2020-01-14T21:04:32Z",
     "goVersion": "go1.13.5",
     "compiler": "gc",
     "platform": "linux/amd64"
   }
 }

Step 5: Start Minikube

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

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 use is Roustabout But you can also use crio or container:

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

The installer will automatically detect KVM and download the KVM driver.

* minikube v1.6.2 on Centos 8.1.1911
* Automatically selected the 'kvm2' driver (alternates: [none])
* Downloading driver docker-machine-driver-kvm2:
    > docker-machine-driver-kvm2.sha256: 65 B / 65 B [-------] 100.00% ? p/s 0s
    > docker-machine-driver-kvm2: 13.86 MiB / 13.86 MiB  100.00% 791.09 KiB p/s
* Downloading VM boot image ...

If you have multiple hypervisors, specify it.

$ minikube start --vm-driver kvm2

Please note that the latest stable Kubernetes version is installed. Adopt --kubernetes-version Flag to specify the version to install. example:

--kubernetes-version='1.16.5'

Wait for the download and setup to complete, and then verify that everything works.

$ minikube start
* minikube v1.6.2 on Centos 8.1.1911
* Automatically selected the 'kvm2' driver (alternates: [none])
* Downloading driver docker-machine-driver-kvm2:
    > docker-machine-driver-kvm2.sha256: 65 B / 65 B [-------] 100.00% ? p/s 0s
    > docker-machine-driver-kvm2: 13.86 MiB / 13.86 MiB  100.00% 791.09 KiB p/s
* Downloading VM boot image ...
    > minikube-v1.6.0.iso.sha256: 65 B / 65 B [--------------] 100.00% ? p/s 0s
    > minikube-v1.6.0.iso: 150.93 MiB / 150.93 MiB [] 100.00% 1.27 MiB p/s 2m0s
* Creating kvm2 VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
* Preparing Kubernetes v1.17.0 on Docker '19.03.5' ...
* Downloading kubelet v1.17.0
* Downloading kubeadm v1.17.0
* Pulling images ...
* Launching Kubernetes ... 
* Waiting for cluster to come online ...
* Done! kubectl is now configured to use "minikube"

Step 6: Basic Minikube operation

of Kubectl The command line tool is configured to use “minikube”.

To check the cluster status, run:

$ 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 profile is located at ~ / .Minikube / machines / minikube / config.json

To view the configuration, use:

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/jkmutai/.minikube/ca.crt
    server: https://192.168.39.2:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/jkmutai/.minikube/client.crt
    client-key: /home/jkmutai/.minikube/client.key

To check the running nodes:

$ kubectl get nodes
NAME       STATUS   ROLES    AGE     VERSION
minikube   Ready    master   2m58s   v1.17.0

Access minikube VM using ssh:

$ minikube ssh

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

$ sudo su -

To stop a running local kubernetes cluster, run:

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

To start the VM, run:

$ minikube start
* minikube v1.6.2 on Centos 8.1.1911
* Selecting 'kvm2' driver from existing profile (alternates: [none])
* Tip: Use 'minikube start -p ' to create a new cluster, or 'minikube delete' to delete this one.
* Starting existing kvm2 VM for "minikube" ...
* Waiting for the host to be provisioned ...
* Preparing Kubernetes v1.17.0 on Docker '19.03.5' ...
* Launching Kubernetes ... 
* Done! kubectl is now configured to use "minikube"

To delete a local kubernetes cluster, use:

$ minikube delete

Step 7: Enable Kubernetes Dashboard

Kubernetes comes with network Dashboard This allows you to manage the cluster without interacting with the command line. The dashboard plugin is installed and enabled by default on minikube.

$ minikube addons list

- addon-manager: enabled
- coredns: disabled
- dashboard: enabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- heapster: disabled
- ingress: disabled
- kube-dns: enabled
- metrics-server: disabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled

To open directly in your default browser, use:

$ minikube dashboard

Get the URL of the dashboard

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

Access the Kubernetes dashboard by opening the URL in your favorite browser. To read further, check:

More guides on Kubernetes:

How to schedule Pods on Kubernetes control plane (master) node

How to join a new Kubernetes Worker node to an existing cluster

Kubernetes cluster deployment on CentOS 7 / CentOS 8 using Ansible and Calico CNI

How to deploy Metrics Server to a Kubernetes cluster

How to manually pull out the container image used by Kubernetes kubeadm

Install and use Helm 3 on a Kubernetes cluster

Sidebar