How to Install Minikube on Ubuntu 22.04 LTS

In this article we are going to cover How to Install Minikube on Ubuntu 22.04 LTS AWS EC2 and deploy an app on Kubernetes cluster using Minikube.

What is Minikube in Kubernetes ?

Minikube creates a single node cluster inside a VM or Cloud Instance. It is good for beginners to learn Kubernetes since you don’t have to create a master and worker node to create a cluster and we can practice basic Kubernetes functions and can also install the Kubernetes dashboard on it.

Minikube System Requirements

  • Minimum 2 CPU’s or more    
  • Minimum 2GB of free memory    
  • Minimum 20GB of free disk space   
  •  Internet connection    
  • Container or virtual machine manager, such as: Docker, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation

Update the system packages on Ubuntu 22.04 LTS AWS EC2

sudo apt update

#1.Install kubectl on Ubuntu 22.04 LTS

Download kubectl binary with curl on Ubuntu 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

Make the kubectl binary executable

chmod +x ./kubectl

Move kubectl to /usr/local/bin/kubectl directory

sudo mv ./kubectl /usr/local/bin/kubectl

To check kubectl version on Ubuntu

kubectl version

Output:

Client Version: version.Info{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"}

#2.Install Docker on Ubuntu 22.04 LTS

Install below packages before installing docker, you can use official docker site

sudo apt-get install  ca-certificates curl gnupg lsb-release

Add Docker official GPG Key

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Setup Docker repository using below command

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the package to take effect

sudo apt-get update

Install Docker on Ubuntu 22.04 LTS using below command

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

To check docker service status on Ubuntu

sudo systemctl status docker

Create group named docker

sudo groupadd docker

Configure to Run docker without sudo permission

sudo usermod -aG docker $USER && newgrp docker

To enable docker service at system startup

sudo systemctl enable docker

To check status of docker service

sudo systemctl status docker

To start/stop docker service

sudo systemctl start/stop docker

#3.Install cri-dockerd on Ubuntu 22.04 LTS

The default network plugin for cri-dockerd is set to cni on Linux/Ubuntu for new Kubernetes version as you can follow GitHub Official repo for same

Clone the below git repo

git clone https://github.com/Mirantis/cri-dockerd.git

To install, on a Linux system that uses systemd, and already has Docker Engine installed

wget https://storage.googleapis.com/golang/getgo/installer_linux
chmod +x ./installer_linux
./installer_linux
source ~/.bash_profile
cd cri-dockerd
mkdir bin
go build -o bin/cri-dockerd

Note: Please wait above command takes some time to complete.

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
sudo systemctl daemon-reload
sudo systemctl enable cri-docker.service
sudo systemctl enable --now cri-docker.socket

#4.Install conntrack package on Ubuntu 22.04 LTS

Install conntrack using apt for minikube on Ubuntu 22.04 LTS

sudo apt-get install -y conntrack

#5.Install crictl package on Ubuntu 22.04 LTS

Install crictl: CLI for kubelet CRI on Ubuntu using below commands follow official crictl GitHub page

VERSION="v1.24.2"
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

#6.Download and Install Minikube on Ubuntu 22.04 LTS

Download and Install Minikube on Ubuntu 22.04 LTS using below commands, To download latest minikube setup refer minikube official download page

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

Make the minikube binary executable

chmod +x minikube

Move minikube to /usr/local/bin/kubectl directory

sudo mv minikube /usr/local/bin/

OR

You can use below command to download latest minikube

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

Install Minikube on Ubuntu 22.04 LTS AWS EC2

sudo install minikube-linux-amd64 /usr/local/bin/minikube

To check minikube version on ubuntu

minikube version

Output:

minikube version: v1.24.0
commit: 76b94fb3c4e8ac5062daf70d60cf03ddcc0a741b

Start the minikube Kubernetes cluster on Ubuntu with calico network plugin

minikube start --network-plugin=cni --cni=calico

OR

minikube start --network-plugin=cni --cni=calico --wait=false

Error:

minikube v1.29.0 on Ubuntu 22.04 (xen/amd64)
Using the none driver based on user configuration
X Exiting due to GUEST_MISSING_CONNTRACK: Sorry, Kubernetes 1.22.3 requires conntrack to be installed in root's path

Solution:

sudo apt-get install -y conntrack

Now start the minikube on Ubuntu

minikube start --network-plugin=cni --cni=calico

Output:

 minikube start --network-plugin=cni --cni=calico
* minikube v1.29.0 on Ubuntu 22.04 (xen/amd64)
* Automatically selected the docker driver. Other choices: none, ssh
! With --network-plugin=cni, you will need to provide your own CNI. See --cni flag as a user-friendly alternative
* 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% 98.55 M
    > gcr.io/k8s-minikube/kicbase...:  407.18 MiB / 407.19 MiB  100.00% 17.17 M
* 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 Calico (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

To Check the status of Minikube

minikube status

Output:

ubuntu@ip-172-31-36-57:~$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

To check Minikube cluster information

kubectl cluster-info

Output:

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'.

To check minikube cluster status

kubectl get nodes

To view minikube cluster events

kubectl get events

To view the kubectl configuration

kubectl config view

Output:

apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/ubuntu/.minikube/ca.crt
    extensions:
    - extension:
        last-update: Sun, 19 Feb 2023 09:16:02 UTC
        provider: minikube.sigs.k8s.io
        version: v1.29.0
      name: cluster_info
    server: https://192.168.49.2:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Sun, 19 Feb 2023 09:16:02 UTC
        provider: minikube.sigs.k8s.io
        version: v1.29.0
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/ubuntu/.minikube/profiles/minikube/client.crt
    client-key: /home/ubuntu/.minikube/profiles/minikube/client.key

Lets create first container on Minikube Cluster using kubectl

kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080

To check pods on minikube using kubectl command

kubectl get pods

Output:

kubectl get pods
NAME             READY   STATUS    RESTARTS   AGE
hello-minikube   1/1     Running   0          37s

We have covered Install Minikube on Ubuntu.

#7:Deploy an app on Minikube Cluster

Lets create deployment on Minikube cluster

kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4

To check deployment on minikube cluster

kubectl get deployment

Output:

kubectl get deployment
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
hello-node   1/1     1            1           31s

Expose the deployment using service on minikube cluster

kubectl expose deployment hello-node --type=NodePort --port=8080

To check service on minikube cluster using kubectl

kubectl get svc

Output:

kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-node   NodePort    10.111.170.87   <none>        8080:32548/TCP   26s
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP          11m

Access the app on minikube cluster using cluster IP

curl -v 13.234.67.176:32548

Output:

*   Trying 13.234.67.176:32548...
* TCP_NODELAY set
* Connected to 13.234.67.176 (13.234.67.176) port 32548 (#0)
> GET / HTTP/1.1
> Host: 13.234.67.176:32548
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.10.0
< Date: Thu, 25 Nov 2021 14:59:53 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
<
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://13.234.67.176:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=*/*
host=13.234.67.176:32548
user-agent=curl/7.68.0
BODY:
* Connection #0 to host 13.234.67.176 left intact

we can access it within the cluster via $(minikube ip):$NODE_PORT

To check minikube internal IP

minikube ip
curl -v 172.31.4.153:32548

To access app on browser using node port

http://13.234.67.176:32548/

Output:

How to Install Minikube on Ubuntu 20.04 LTS 1

To delete service on minikube cluster using kubectl

kubectl delete service hello-node

To delete deployment on minikube cluster using kubectl

kubectl delete deployment hello-node

To stop minikube cluster

minikube stop

Output:

* Stopping node "minikube"  ...
* 1 node stopped.

To delete minikube cluster

minikube delete

Output:

* Uninstalling Kubernetes v1.22.3 using kubeadm ...
* Deleting "minikube" in none ...
* Removed all traces of the "minikube" cluster.

Error:

minikube start –vm-driver=none

* minikube v1.26.1 on Ubuntu 22.04 (xen/amd64)

* Using the none driver based on user configuration

* Starting control plane node minikube in cluster minikube

* Running on localhost (CPUs=2, Memory=3922MB, Disk=19673MB) …

* Exiting due to NOT_FOUND_CRI_DOCKERD:

* Suggestion:

    The none driver with Kubernetes v1.24+ and the docker container-runtime requires cri-dockerd.

    Please install cri-dockerd using these instructions:

Solution

Follow this GitHub Page or step no #3

Error:

X Exiting due to HOST_JUJU_LOCK_PERMISSION: Failed to start host: boot lock: unable to open /tmp/juju-mkc8ab01ad3ea83211c505c81a7ee49a8e3ecb89: permission denied

* Suggestion: Run ‘sudo sysctl fs.protected_regular=0’, or try a driver which does not require root, such as ‘–driver=docker’

* Related issue: https://github.com/kubernetes/minikube/issues/6391

Solution:

sudo sysctl fs.protected_regular=0

Error: 

X Exiting due to RUNTIME_ENABLE: Temporary Error: sudo crictl version: exit status 1

stdout:

stderr:

sudo: crictl: command not found

Solution:

Follow below links

https://github.com/kubernetes-sigs/cri-tools#install-crictl
https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md

Conclusion:

In this article we have covered How to Install Minikube on Ubuntu 22.04 LTS AWS EC2 and deploy an app on Kubernetes cluster using Minikube.

Related Articles:

Reference:

Minikube official page

Calico Official page

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

2 thoughts on “How to Install Minikube on Ubuntu 22.04 LTS”

  1. thank you so much for this article, trying to install minikube on ubuntu instance from last 2 days but not able to do it, after watching so many youtube videos and all but your article helps me in one go. thank you

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap