How to Install Minikube on Ubuntu 22.04?

In this tutorial we are going to teach you to install, configure and use Minikube Kubernetes cluster on Ubuntu 22.04. We will show you how to deploy containerized applications on the Minikube Kubernetes cluster.

How to Install Minikube on Ubuntu 22.04?

Minikube Tutorial - How to Install Minikube on Ubuntu 22.04?

Minikube is one of the best Kubernetes clusters for getting started and running the local development environment. This software is good if you want to learn Kubernetes or to set up a local development environment for developing and deploying containerized applications on the Kubernetes cluster. Developers can easily use this for local development. This Kubernetes cluster can also be used to test POC applications. It can also be used in the QA environment. Minikbe can be set up in a single machine and run using the Docker engine. So, its good for the developers to learn Minikube distribution of Kubernetes.

In this tutorial we are going to teach you Minikube installation, configuration and use of this cluster to run Docker images. Setup of Minikube is done on the Ubuntu 22.04 Desktop operating system but you can follow the steps provided here to setup Minikube on other versions of Ubuntu operating system. You can follow the steps given here and easily setup this on the Ubuntu Server operating system also. So, let's get started and set up Minikube on the Ubuntu 22.04 Desktop Operating system.

Step 1: Update your Ubuntu 22.04 System

First of all you should update your system by running following commands:

sudo apt update
sudo apt upgrade

Above command is necessary as it updates your system with the latest releases of the software. It will also update any security patch that have been released for your Ubuntu 22.04 version. So, this is an good idea to update your system regularly.

Here is the screen shot of the system update process:

Update Ubuntu Linux System

After updating the system software we will proceed with the next step.

Step 2: Install dependencies of Minikube

The next step is to download and install the dependencies required to run Minikube Kubernetes server. Minikube dependencies can be installed easily with the apt command. Here is the command to install Minikube dependencies on your Ubuntu 22.04 Operating system:

sudo apt install -y curl wget apt-transport-https

Here is the output of the above step:

oseindia@roseindia-VirtualBox:~/Desktop$ sudo apt install -y curl wget apt-transport-https

[sudo] password for roseindia: 

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

wget is already the newest version (1.21.2-2ubuntu1).

wget set to manually installed.

curl is already the newest version (7.81.0-1ubuntu1.7).

apt-transport-https is already the newest version (2.4.8).

The following packages were automatically installed and are no longer required:

  libflashrom1 libftdi1-2 python3-attr python3-docker python3-dockerpty

  python3-docopt python3-dotenv python3-jsonschema python3-pyrsistent

  python3-texttable python3-websocket

Use 'sudo apt autoremove' to remove them.

0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.

roseindia@roseindia-VirtualBox:~/Desktop$ 

Here is the screen shot of the step:

Update System for Minikube installation

After the installation of Minikube dependency libraries our system is ready for the installation of Minikube. In the next step I will show you the command to install Minikube on your system.

Step 3: Installing Minikube software packages

In this step we are going to install Minikube software packages. We will use wget command to download the Minikube binary:

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

This will download the minikube binary as shown below:

Downloading Minikube binary

Above command downloads the Minikube binary "minikube-linux-amd64".

Step 4: Copying binary to /usr/local/bin directory and providing execute permission

The next step is to copy the file to /usr/local/bin directory and provide the executable permission to this file. So, run the following command to do so:

sudo cp minikube-linux-amd64 /usr/local/bin/minikube
sudo chmod +x /usr/local/bin/minikube

Now you can check the Minikube version by running the following command:

minikube version

Here is the screenshot of the above steps:

Minikube installation and version check

So, We have successfully installed Minikube Kubernetes. Now we will see how to run it and use. Follow the steps below to run and test Minikube on your Ubuntu 22.04 operating system. Minikube is good and easy to install Kubernetes distribution for easy development and testing of the applications.

Step 5: Installing and checking kubectl tool

Now we will proceed with the installation of kubectl tool which is used to interact with Kubernetes cluster and run command to mange application deployment. You can use this tool to connect to the Kubernetes API server and issue commands for deployment of new pods, stop running pods, replicate running pods, scale up etc. So, kubectl tool is powerful command line utility and it can installed with the described here.  First of all you have to download the latest version of this tool with following 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

Now we have to move the minikube executable file to /usr/local/bin directory and make it executable. Here is the command do to do:

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

After completing above step you can verify kubectl with following command:

kubectl version -o yaml

Here is the output of all of the above steps:

oseindia@roseindia-VirtualBox:~/Desktop$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 45.7M  100 45.7M    0     0  22.0M      0  0:00:02  0:00:02 --:--:-- 22.0M

roseindia@roseindia-VirtualBox:~/Desktop$ ls

kubectl

roseindia@roseindia-VirtualBox:~/Desktop$ chmod +x kubectl

sudo mv kubectl /usr/local/bin/

[sudo] password for roseindia: 

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl version -o yaml

clientVersion:

  buildDate: "2023-01-18T15:58:16Z"

  compiler: gc

  gitCommit: 8f94681cd294aa8cfd3407b8191f6c70214973a4

  gitTreeState: clean

  gitVersion: v1.26.1

  goVersion: go1.19.5

  major: "1"

  minor: "26"

  platform: linux/amd64

kustomizeVersion: v4.5.7



The connection to the server localhost:8080 was refused - did you specify the right host or port?

roseindia@roseindia-VirtualBox:~/Desktop$ 

Here is the screen of the kubectl installation of my Ubuntu 22.04 Desktop operating system:

Download and Install kubectl on Ubuntu 22.04

Above steps will help you in installation and testing kubectl utility on your Ubuntu 22.04 operating system. After installation we have tested kubectl tool. The next step is to start Minikube Kubernetes server and test few deployments. Let's do it in the next steps.

Step 6: Starting Minikube Kubernetes server

In this step we are going to run the Minikube on our Ubuntu 22.04 and then check the status of this service. You can start Minikube with following command: 0

minikube start --driver=docker

There are many options that you can provide with the minikube start command. For example you can use following command to start minikube with 2 cpus:

minikube start --addons=ingress --cpus=2 

Here is the output of running the minikube start --driver=docker command:

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl -version

error: invalid argument "ersion" for "-v, --v" flag: strconv.ParseInt: parsing "ersion": invalid syntax

See 'kubectl --help' for usage.

roseindia@roseindia-VirtualBox:~/Desktop$ minikube start --driver=docker

  minikube v1.29.0 on Ubuntu 22.04 (vbox/amd64)

  Using the docker driver based on user configuration

  Using Docker driver with root privileges

  Starting control plane node minikube in cluster minikube

  Pulling base image ...

  Downloading Kubernetes v1.26.1 preload ...

    > preloaded-images-k8s-v18-v1...:  397.05 MiB / 397.05 MiB  100.00% 19.61 M

    > gcr.io/k8s-minikube/kicbase...:  407.18 MiB / 407.19 MiB  100.00% 9.70 Mi

  Creating docker container (CPUs=2, Memory=2200MB) ...

  Preparing Kubernetes v1.26.1 on Docker 20.10.23 ...

    ▪ Generating certificates and keys ... 

    ▪ Booting up control plane ...

    ▪ Configuring RBAC rules ...

  Configuring bridge CNI (Container Networking Interface) ...

    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5

  Verifying Kubernetes components...

  Enabled addons: storage-provisioner, default-storageclass

  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

roseindia@roseindia-VirtualBox:~/Desktop$ minikube status

minikube

type: Control Plane

host: Running

kubelet: Running

apiserver: Running

kubeconfig: Configured



roseindia@roseindia-VirtualBox:~/Desktop$ 

Screen shot of the above step taken from Ubuntu 22.04 Desktop machine: 1

Run Minikube on Ubuntu 22.04 from terminal

Above command confirms that our Minikube Kubernetes cluster is running fine and it can be used to deploy docker containers. You can run the following commands to get the details and url of the API server:

kubectl cluster-info
kubectl get nodes

Should see the following output after running the above commands: 2

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl cluster-info

Kubernetes control plane is running at https://192.168.49.2:8443

CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy



To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl get nodes

NAME       STATUS   ROLES           AGE   VERSION

minikube   Ready    control-plane   45m   v1.26.1

roseindia@roseindia-VirtualBox:~/Desktop$ 

Screen shot of the out on the Ubuntu 22.04 OS:

Minikube Cluster info command

From the above output you can recognize that the Kubernetes control plane is running at https://192.168.49.2:8443. You can use the above URL to submit your Dockerized applications to run on the Kubernetes cluster. 3

Step 6: Understanding and Installing Minikube add-ons

The Minikube extensions are developed to add more functionality to the Minikube Kubernetes cluster and it helps in using Kubernetes cluster easily. To view all the available add-ons run the following command:

minikube addons list

Above command lists down all the supported minikube pluging for Kubernetes. Here is the list at the time of writing of this tutorial:

Minikube addons list
4

Above is the list of add-ons and you can install any of it using the command minikube addons enable <addon name>.

Step 7: Installing Minikube dashboard

Minikube addon dashboard adds the Kubernetes monitoring dashboard on to your Minikube Kubernetes cluster. With this dashboard you will be able to view the status of the running pods its logs and much more. To install dashboard run the following command:

minikube addons enable dashboard

Output of the dashboard addons installation process: 5

roseindia@roseindia-VirtualBox:~/Desktop$ minikube addons enable dashboard

  dashboard is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.

You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS

    * Using image docker.io/kubernetesui/dashboard:v2.7.0

    * Using image docker.io/kubernetesui/metrics-scraper:v1.0.8

  Some dashboard features require the metrics-server addon. To enable all features please run:

	minikube addons enable metrics-server	

  The 'dashboard' addon is enabled

roseindia@roseindia-VirtualBox:~/Desktop$ 

The screen shot of enabling dashboard on the Minikube Kubernetes cluster is show below:

Installing Minikube Dashboard

Above command enables the Kubernetes Dashboard on the cluster. 6

Step 8: Accessing Kubernetes Dashboard in browser

You can run the following command to get the url to view the dashboard in the web browser:

minikube dashboard

Here is the screen shot of the above command:

Update Ubuntu Linux System0 7

The minikube dashboard command also opens the browser and displays the Kubernetes dashboard where you can see the status of your cluster. Here is the screenshot of the same:

Update Ubuntu Linux System1

In the above screenshot we can see there is no Pods. Above Dashboard shows Jobs, Pods, Replica Sets and other services. 8

Step 9: Enabling Ingress controller add-on

Now we will understand the steps to install Kubernetes Ingress add-ons on the Minikube Kubernetes cluster. Ingress in Kubernetes is an API object that is used for controlling the routing rules within the Kubernetes cluster. This is usually based on the HTTP or HTTPS protocols for managing the traffic inside the cluster. The Ingress service is the best choice in the production deployment of the Kubernetes cluster. This service can be used by the users to expose the services running inside the Kubernetes cluster. It's easy process and does not require creation of multiple load balancers or manually service exposure.

Run the following command to enable Ingress on your Minikube Kubernetes cluster:

minikube addons enable ingress

The screenshot of the above step is below: 9

Update Ubuntu Linux System2

Installation log is below:

roseindia@roseindia-VirtualBox:~/Desktop$ minikube addons enable ingress

  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.

You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS

    * Using image registry.k8s.io/ingress-nginx/controller:v1.5.1

    * Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20220916-gd32f8c343

    * Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20220916-gd32f8c343

  Verifying ingress addon...

  The 'ingress' addon is enabled

roseindia@roseindia-VirtualBox:~/Desktop$ 

Step 10: Install Nginx docker image and test Kubernetes cluster

Nginx is an open source HTTP server and proxy server that can be used to server HTTP requests and also work as a reverse proxy server. Nginx can be used to serve HTTP, HTTPS, mail proxy and reverse proxy. Nginx can also be used as a reverse proxy server and this software is released under the terms of the 2-clause BSD license. In this step we will install Nginx server on the Kubernetes cluster and then test. Here is the command to install Nginx server on the Kubernetes cluster: 0

kubectl create deployment my-nginx --image=nginx

Here is the output of the above deployment command:

oseindia@roseindia-VirtualBox:~/Desktop$ kubectl create deployment my-nginx --image=nginx

deployment.apps/my-nginx created

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl get pods

NAME                        READY   STATUS    RESTARTS   AGE

my-nginx-5987c6f9b8-5wm48   1/1     Running   0          15s

roseindia@roseindia-VirtualBox:~/Desktop$ 

Screen shot of the above command taken on the Ubuntu 22.04 Desktop:

Update Ubuntu Linux System3 1

In the Kubernetes Dashboard and also in the pods list we can see the Niginx deployment. So, through above command you can easily deploy Nginx Docker image on the Kubernetes cluster.

Step 11: Expose Nginx Pod through service

Now we will show you how you can create a service and expose running Nginx instance to the outside world. Here is the command to create a service for exposing the Nginx Pod to outside world:

kubectl expose deployment my-nginx --name=my-nginx-svc --type=NodePort --port=80
kubectl get svc my-nginx-svc

If you run the above commands you will get following output: 2

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl expose deployment my-nginx --name=my-nginx-svc --type=NodePort --port=80

service/my-nginx-svc exposed

roseindia@roseindia-VirtualBox:~/Desktop$ kubectl get svc my-nginx-svc

NAME           TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE

my-nginx-svc   NodePort   10.98.252.213   <none>        80:32526/TCP   23s

roseindia@roseindia-VirtualBox:~/Desktop$ 

Here is the screenshot of the process:

Update Ubuntu Linux System4

In the above screen shot you can see the IP address of the Nginx pod. This IP address is internal to the Kubernetes cluster and can't be accessed from outside. So, we will create a service and expose the Nginx Pod to the outside world. Here is the command for the same: 3

minikube service my-nginx-svc --url

Above command gives the following output:

roseindia@roseindia-VirtualBox:~/Desktop$ minikube service my-nginx-svc --url

http://192.168.49.2:32526

roseindia@roseindia-VirtualBox:~/Desktop$ 

If you type the above url in the browser, Nginx home page will be displayed as shown below:

Update Ubuntu Linux System5 4

You can see the Nginx page and the url of the service on Kubernetes cluster.

Step 12: Scale up the deployments

You can scale up the deployments of the nginx instances by running following command:

kubectl scale --replicas=3 deployment.apps/my-nginx

Above command will display following output: 5

Update Ubuntu Linux System6

Step 13: Delete the deployments

First of all get the deployments with the following command:

kubectl get deploy

Then delete the deployment with following command: 6

kubectl delete deploy my-nginx
kubectl delete svc my-nginx-svc

Above command will delete my-nginx pod and my-nginx-svc service.

Step 14: Stop Minikube

You can stop Minikube with following command: 7

minikube stop

To delete Minikube cluster you can run following command

minikube delete

Here is the screen shot of the stop and delete operation:

Update Ubuntu Linux System7 8

Step 15: Start Minikube again

If you want to start the minikube again then you can run the following command:

minikube start --driver=docker

Above command will again start minikube on you Ubuntu 22.04 Desktop operating system.

In this tutorial we have learned how to install and use Minikube Kubernetes cluster on the Ubuntu 22.04 operating system. This tutorial apply for both Server and Desktop operating system. Do you want to learn Kubernetes and master this cluster then checkout our Kubernetes Tutorials. 9