Kubernetes can be installed and configured in a variety of ways, including on personal computers, physical servers, virtual machines, and as a cloud service. We will learn how to install a single node Kubernetes cluster using Minikube in CentOS Linux.
For the purpose of this guide, we will install Minikube on CentOS 7 natively running on top of the virtual machine layer. Before installing Kubernetes, you need to have a basic understanding of Kubernetes and its architecture and containers. Please refer to our previous article attached below to know about the concepts.
Heads Up: This guide has been officially tested on CentOS. However, the installation steps are same for Fedora, RHEL, and its clones such as AlmaLinux and Rocky Linux. If you're on AlmaLinux and/or Rocky Linux, just replace yum
with dnf
in the commands given throughout this guide.
Table of Contents
What is Minikube?
The Kubernetes community has officially released Minikube, a single-node Kubernetes distribution. It is a Open Source software that allows you to create a single-node Kubernetes cluster on your home workstation.
Minicube creates a virtual computer and runs a Kubernetes cluster on it, allowing you to test in a Kubernetes environment on your local machine. It's great for anyone who wants to install Kubernetes but only has a limited amount of system resources.
The main aspect to remember about Minikube is that it lacks a separate Kubernetes master and Kubernetes worker node architecture.
All Kubernetes components are packed together as an all-in-one solution here. One system serves as both a master and a worker node.
What is the purpose of Minikube?
Minikube is mostly used to obtain hands-on experience with Kubernetes. Minikube is an easy way to try things out and test apps because huge clusters aren't always available.
Even those who are already familiar with Kubernetes will find Minikube to be an excellent learning environment, as it allows for so much experimentation.
Prerequisites to install Minikube
- Minimum 2 CPUs.
- Minimum 2GB of Physical Memory (RAM).
- 20GB of Disk Space.
- Internet connection to download packages.
- Install Docker engine - Container management system.
- Install Conntrack.
Steps to install Kubernetes in CentOS
Installing Kubernetes on CentOS consists of the following steps.
Heads Up: All commands given below should be run as root
or sudo
user.
Step 1 - Install Docker
First, we will add Docker repository in our system.
To do so, create a file named docker.repo
under /etc/yum.repos.d/
directory:
# vi /etc/yum.repos.d/docker.repo
Add the following lines in it:
[docker] baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/ gpgcheck=0
Press ESC and type :wq
to save the file and close it.
Verify the installed and enabled repositories using below command:
# yum repolist
Docker repository is added. Now, rRun Install Docker community edition (ce):
# yum -y install docker-ce
Start and enable the Docker:
# systemctl start docker
# systemctl enable docker
Verify the Docker status:
# systemctl status docker
Step 2 - Install Conntrack
Conntrack is part of the Netlifier framework. It's required for Kubernetes sophisticated networking to run well, as nodes must keep track of connections between thousands of pods and services.
To install Conntrack on CentOS, run:
# yum -y install conntrack
Step 3 - Install Kubernetes Client (Kubectl)
Kubectl is the Command Line tool to work with Kubernetes. You can download kubectl using below command:
# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
Assign executable permission to keubectl:
# chmod +x kubectl
Move kubectl package to your $PATH (E.g. /usr/local/bin
)
# mv kubectl /usr/local/bin/
Verify the installation by checking kubeclt version:
# kubectl version --client -o json
Here, the "-o json
" flag will give you the output in JSON format.
Sample output:
{ "clientVersion": { "major": "1", "minor": "22", "gitVersion": "v1.22.4", "gitCommit": "b695d79d4f967c403a96986f1750a35eb75e75f1", "gitTreeState": "clean", "buildDate": "2021-11-17T15:48:33Z", "goVersion": "go1.16.10", "compiler": "gc", "platform": "linux/amd64" } }
Step 4 - Install Minikube
Download the minicube package using command:
# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Give executable permission to minicube package:
# chmod +x minikube-linux-amd64
Finally, move the Minikube package to /usr/local/bin
:
# mv minikube-linux-amd64 /usr/local/bin/minikube
Minikube setting is done, and you can verify the installation by checking the version:
# minikube version
Sample output:
minikube version: v1.24.0 commit: 76b94fb3c4e8ac5062daf70d60cf03ddcc0a741b
Start the Minikube using command:
# minikube start
Check the status of Minikube:
# minikube status
Sample output:
minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured
You can get the nodes status and roles using kubectl
command:
# kubectl get nodes
Sample output:
NAME STATUS ROLES AGE VERSION ostechnix Ready control-plane,master 26h v1.22.3
Step 5 - Access the Kubernetes UI dashboard
To access Kubernetes dashboard via a web browser, run:
# minikube dashboard --url
This will generate an URL and display it in the standard output as shown in the below output.
* Verifying dashboard health ... * Launching proxy ... * Verifying proxy health ... http://127.0.0.1:36526/api/v1/namespaces/kube-dashboard/services/https:kubernetes-dashboard:/proxy/
Copy the URL and paste it in the browser. Here is how Kubernetes web dashboard looks like.
When you access Dashboard on an empty cluster, you'll see the welcome page. This page contains links to the Dashboard tour as well as a deploy your first containerized application.
Conclusion
We have gone through the installation steps of Kubernetes with Minikube. This can be used for learning and testing purpose in our local system or VM. We will cover other installation methods and Kubernetes operation in the next articles.
Resource: