Minikube is single node Kubernetes (k8s) cluster and can be installed inside a virtual machines. It generally used for test and development environment. Anyone who is new to Kubernetes and want to learn it then minikube is recommended setup. As it can be deployed very easily almost on all the linux distributions likee Ubuntu, RHEL, CentOS and Debian.
In this guide, we will learn how to install Minikube on Ubuntu 22.04 (Jammy Jellyfish) and Ubuntu 20.04 (Focal Fossa) LTS. Steps would be identical on the ubuntu version.
Minimum system requirements for Minikube
- 2GB RAM or more
- 2 CPU Core or more
- 20 GB hard disk or more
- User with Sudo Privilege
- Docker or VirtualBox or KVM
- Stable Internet Connection
Let’s deep dive into the installation steps of Minikube,
1 ) Install Minikube Package Dependencies
Login to your Ubuntu 22.04 / Ubuntu 20.04 system and run following commands to install minikube package dependencies.
$ sudo apt update $ sudo apt install curl wget apt-transport-https -y
Note: In this guide, I am using docker as base for Minikube and assuming is already installed on your system. In case it is not installed the refer below:
2 ) Download Minikube binary with wget
Run beneath wget command to download minikube binary,
$ wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Copy the downloaded minikube binary to /usr/local/bin with cp command and also don’t forget to set executable permissions on it.
$ sudo cp minikube-linux-amd64 /usr/local/bin/minikube $ sudo chmod +x /usr/local/bin/minikube
View the minikube version by running,
$ minikube version minikube version: v1.25.2 commit: 362d5fdc0a3dbee389b3d3f1034e8023e72bd3a7 $
3) Download kubectl Utility
Kubectl is a command line utility which is used to interact with Kubernetes cluster. Using kubectl we deploy different resources in Kubernetes cluster.
To download and install kubectl use following wget 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
Output
Move kubectl binary to /usr/local/bin and set execute permissions on it.
$ chmod +x kubectl $ sudo mv kubectl /usr/local/bin/
Verify the Kubectl version using beneath command,
$ kubectl version
Output
4) Start Minikube with Docker Driver
As we are using docker as a base for minikube, so run following minikube command to start it
$ minikube start --driver=docker
Great, above output confirms that minikube has been started successfully.
Note: In case, you want pass customize resource parameters while starting the minikube, use below
$ minikube start --addons=ingress --cpus=4 --cni=flannel --install-addons=true --kubernetes-version=stable --memory=6g
5) Verify Minikube and Kubernetes Cluster Status
To verify the minikube status, run
$ minikube status
To Verify Kubernetes cluster status, run
$ kubectl cluster-info
Output of above commands would look like below:
5) Enable Addons on Minikube
When we install minikube, only few addons are enabled. To view all the addons and their status, run
$ minikube addons list
To Enable addons, run
$ minikube addons enable ingress $ minikube addons enable dashboard
6) Test Kubernetes Cluster
To test Kubernetes cluster, let deploy a nginx based deployment using following kubectl command,
$ kubectl create deployment myapp --image=nginx --replicas=2 $ kubectl get deployment myapp NAME READY UP-TO-DATE AVAILABLE AGE myapp 2/2 2 2 30s $
Create a service by exposing the deployment,
$ kubectl expose deployment myapp --type=NodePort --port=80
Get the service url, by running
$ minikube service myapp --url http://192.168.49.2:31441 $
Now try access the app using the URL,
$ curl http://192.168.49.2:31441
Perfect, above output confirms that we can access nginx web page.
7) Access Kubernetes dashboard
To access Kubernetes dashboard, run following command
$ minikube dashboard --url
Click on the url which is displayed in the output, it will open the Kubernetes dashboard,
8) Manage Minikube Cluster
To stop the minikube, run
$ minikube stop
To start the minikube, run
$ minikube start
To delete the minikube cluster, first stop it and then delete it
$ minikube delete
That’s all from this guide. I hope you have found it informative, please don’t hesitate to share your queries and feedback in below comments section.