Minikube Installation on Linux (Ubuntu 20.04)
Hello warmly welcome you to this blog, my name is Osama Saeed, and I am a DevOps Engineer. If you are here on my blog, I am sure that you are struggling with the Installation of Minikube on Linux (ubuntu 20.04) and you are helpless to found anything about it and need quick solution, please trust me and follow till the end to install Minikube on your virtual machine with OS Linux (Ubuntu 20.04). The purpose of writing this blog is to help others. I struggled a lot and read different blogs and watch dozens of videos, but I have not found any solution for the setup of Minikube, and question remains How to Install Minikube? and then I start compiling things from different resources and finally I am able to setup Minikube, which I mentioned below Please read till the end. Thanks!
Minikube: Minikube is an open-source tool that enables developers to run a single-node Kubernetes cluster. It is designed to facilitate the development and testing of applications that are intended to run on a full-scale Kubernetes cluster. Minikube provides a lightweight Kubernetes implementation and can be installed on various operating systems, including Windows, macOS, and Linux. It creates a virtual machine on the host system and deploys a minimal Kubernetes cluster within it. This cluster includes a single master node and worker nodes, allowing developers to emulate the behavior of a larger production Kubernetes environment. With Minikube, developers can easily create and manage Kubernetes resources, such as pods, services, and deployments. It enables them to test their applications’ behavior in a Kubernetes environment without the need for a dedicated infrastructure.
Kubernetes: Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It provides a robust and scalable framework for running applications across a cluster of machines. Kubernetes organizes containers into logical groups called “pods,” which are the smallest deployable units in the Kubernetes ecosystem. Containers within a pod share the same network namespace and can communicate with each other using localhost. Kubernetes manages pods and ensures that they are running and healthy by monitoring their status and restarting or rescheduling them if necessary. Kubernetes is highly extensible and integrates with other tools and services in the ecosystem. It supports various container runtimes, including Docker, container, and others, giving users flexibility in their choice of containers. It also provides an extensive set of APIs and command-line tools, such as Kubectl, for interacting with and managing Kubernetes clusters.
Preparing the Environment for Minikube on Ubuntu 20.04
Virtual Machine requirements:
- Min 2 CPUs but suggested 4 CPUs.
- Min 2GB of free memory suggested 4GB.
- 20GB of free disk space.
- Good Internet connection.
- Container or virtual machine manager: Docker.
- Kubectl: Kubectl is a command-line interface (CLI) tool used for interacting with Kubernetes clusters. Kubectl provides a comprehensive set of commands and options to interact with Kubernetes clusters, making it a versatile tool for managing and operating Kubernetes deployments. It simplifies the management of containerized applications and offers a convenient way to control and monitor resources within a Kubernetes environment.
Installation: Command for latest Kubectl download for ubuntu 20.04:
curl -LO “https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl”
Or you can also visit official link: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
after downloading Kubectl you required to give executable permission which is:
chmod +x ./kubectl
user local bin:
sudo mv ./kubectl /usr/local/bin/kubectl
If every step above is successful we can install Kubectl successfully, verify version:
kubectl version
- Dockers: Docker is an open-source platform that enables developers to automate the deployment and running of applications inside containers. It provides a lightweight and portable environment that encapsulates an application and its dependencies, allowing it to run consistently across different operating systems and infrastructure.
Installation: To install Docker on ubuntu 20.04 click on link and follow the instructions
https://docs.docker.com/engine/install/ubuntu/
or follow the below mentioned commands to install docker.
- Setup Repository:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
- Add Docker official GPG key run following commands step by step:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
“deb [arch=”$(dpkg –print-architecture)” signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
“$(. /etc/os-release && echo “$VERSION_CODENAME”)” stable” | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install Docker Engine, Compose and Container:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Hurry you install docker successfully verify by the command.
docker –version
- Create Docker user and permission:
sudo usermod -aG docker $USER
- Cri-Docker Installation:
clone the GitHub repo:
git clone https://github.com/Mirantis/cri-dockerd.git
Install GO Installer
– Run below commands as root one by one:
wget https://storage.googleapis.com/golang/getgo/installer_linux
chmod +x ./installer_linux
./installer_linux
source ~/.bash_profile
Configure cri-docker
cd cri-dockerd
mkdir bin
go build -o bin/cri-dockerd (It may take some time please wait patiently)
mkdir -p /usr/local/bin
sudo install -o root -g root -m 0755 bin/cri-dockerd /usr/local/bin/cri-dockerd
sudo cp -a packaging/systemd/* /etc/systemd/system
sudo sed -i -e ‘s,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,’ /etc/systemd/system/cri-docker.service
systemctl daemon-reload
systemctl enable cri-docker.service
systemctl enable –now cri-docker.socket
- Minikube Installation:
For the installation of Minikube you can either follow official documentation https://minikube.sigs.k8s.io/docs/start/
or you can use following commands to install Minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
before starting Minikube service, install conntrack and crictl otherwise you get error
sudo apt-get install -y conntrack
and then follow the steps in link https://github.com/kubernetes-sigs/cri-tools#install-crictl or following commands to install crictl
VERSION=”v1.26.0″
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
rm -f crictl-$VERSION-linux-amd64.tar.gz
To start Minikube use following command:
sudo minikube start –driver=none
To check the Minikube status use the command.
minikube status
kubectl config view
Hurray!! We setup Minikube successfully if you made till this point.
To interact with your cluster and explore more visit official documentation:
https://minikube.sigs.k8s.io/docs/start/
Conclusion: In conclusion, the installation and setup of Minikube on an Ubuntu 20.04 virtual machine (VM) involves creating an environment that includes the installation of Kubectl, Docker, and the cri-docker runtime. This setup provides developers with a local Kubernetes cluster for development and testing purposes.
To begin, Ubuntu 20.04 is chosen as the operating system for the VM due to its stability and compatibility with Minikube, Kubectl, Docker, and cri-docker. The installation process follows the official documentation and guidelines provided by the respective projects. First, Kubectl is installed, which is the command-line interface for interacting with Kubernetes clusters. It allows users to manage and control various aspects of the cluster, including creating and managing resources, inspecting cluster state, scaling deployments, and executing administrative tasks. Next, Docker is installed on Ubuntu 20.04 VM. Docker allows for containerization, providing a lightweight and efficient runtime environment for applications. It enables developers to package their applications and dependencies into containers, ensuring consistency and portability across different systems. To enable Minikube to use Docker as the container runtime, cri-docker is installed. Cri-docker acts as the interface between Kubernetes and Docker, enabling Kubernetes to manage containers using Docker as the runtime environment.
Once the prerequisites are installed, the next step is to install Minikube itself. Minikube provides a lightweight Kubernetes implementation on a single VM, allowing developers to simulate a full-scale Kubernetes cluster on their local machines. This setup enables them to develop, test, and experiment with Kubernetes applications without the need for a dedicated infrastructure or access to a remote cluster. By installing Minikube, Kubectl, Docker, and cri-docker on an Ubuntu 20.04 VM, developers have a fully functional local Kubernetes environment. They can create and manage Kubernetes resources, deploy applications in containers, and test their behavior within the cluster. This setup facilitates efficient development and testing workflows, reducing the reliance on remote clusters and simplifying the deployment process.
Author
Osama Saeed
Associate Consultant