This tutorial has been written to help you install Minikube on CentOS 8 / CentOS 7 with KVM Hypervisor. Minikube is an open source tool designed to enable developers and system administrators to bootstrap a single node Kubernetes cluster in their local machine – Laptops, Desktop workstations in minutes. This is ideal for development and POC purposes, but not for running Production workloads.
For installation of Minikube on Ubuntu / Debian Linux system, check: How to install Minikube on Ubuntu / Debian Linux. In a nutshell, Minikube packages and configures a Linux VM, then installs Docker and all Kubernetes components into it. Which you can manage and deploy applications from kubectl running in the host system.
Kubernetes Supported features
Some of the features which you can run from Kubernetes running in Minikube are:
- 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 with KVM on a CentOS 8 / CentOS 7 Linux machine.
Step 1: Update system
Run the following commands to update all system packages to the latest release:
sudo yum -y update
Step 2: Install KVM Hypervisor
As stated earlier, we’ll use KVM as Hypervisor of choice for the Minikube VM. Here is our complete guide on the installation of KVM on CentOS / RHEL 8.
How To Install KVM on RHEL 8 / CentOS 8 Linux
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 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 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
Step 3: Download 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.6.2 commit: 54f28ac5d3a815d1196cd5d57d707439ee4bb392
Step 4: Install kubectl
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 -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: Starting minikube
Now that components are installed, you can start minikube. VM image will be downloaded and configured for 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 be used is docker, but you can also use crio or containerd:
$ minikube start --container-runtime=cri
$ minikube start --container-runtime=containerd
The installer will automatically detect KVM and download 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 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='1.16.5'
Wait for the download and setup to finish then confirm that everything is working fine.
$ 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: Minikube Basic operations
The kubectl command line tool is configured to use “minikube“.
To check 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 configuration file is located under ~/.minikube/machines/minikube/config.json
To View Config, 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 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 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 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-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 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:
- Hello Minikube Series: https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/
- Minikube guides for newbies: https://kubernetes.io/docs/getting-started-guides/minikube/
More guides on Kubernetes:
How To Schedule Pods on Kubernetes Control plane (Master) Nodes
How To Join new Kubernetes Worker Node to an existing Cluster
Deploy Kubernetes Cluster on CentOS 7 / CentOS 8 With Ansible and Calico CNI
How To Deploy Metrics Server to Kubernetes Cluster
How To Manually Pull Container images used by Kubernetes kubeadm