In this article we are going to cover How to Install minikube on Ubuntu 22.04 LTS | kubernetes with minikube on ubuntu, Install kubectl on Ubuntu 20.04 LTS

What is MiniKube?

Minikube is a tool that enables you to run a single-node Kubernetes cluster on your local machine. Kubernetes is a powerful container orchestration platform used for managing containerized applications in production environments. While Kubernetes is typically used for large-scale deployments, Minikube is designed for local development and testing purposes.

Features and use cases for Minikube:

  1. Local Kubernetes Cluster: Minikube allows you to set up and run a minimal, self-contained Kubernetes cluster on your development machine. This cluster includes the core components of Kubernetes, such as the API server, scheduler, controller manager, and etcd database.
  2. Development and Testing: Minikube is primarily used by developers and testers to develop, test, and debug Kubernetes applications locally before deploying them to a production Kubernetes cluster. This makes it easier to iterate and develop containerized applications without the need for a full-scale Kubernetes cluster.
  3. Isolated Environments: Minikube provides an isolated environment, so you can experiment with Kubernetes features and configurations without affecting your production systems. It’s an excellent tool for learning and getting hands-on experience with Kubernetes.
  4. Cross-Platform Support: Minikube is designed to work on various operating systems, including Linux, macOS, and Windows, making it accessible to a broad range of developers.
  5. Driver Support: Minikube supports different virtualization drivers, such as VirtualBox, KVM, HyperKit (macOS), and Docker, allowing you to choose the virtualization solution that best fits your environment.
  6. Easy Setup: Minikube simplifies the setup and management of a local Kubernetes cluster. You can start a cluster with a single command, and Minikube takes care of the details like configuring the kubeconfig file, setting up the necessary components, and providing access to the cluster.
  7. Add-Ons and Extensions: Minikube supports add-ons and extensions that provide additional functionality, such as dashboard access, metrics, and more, to enhance your local Kubernetes environment.

Overall, Minikube is a valuable tool for developers and DevOps professionals who want to work with Kubernetes in a local, controlled environment. It helps streamline the development and testing process, making it easier to build and deploy containerized applications on Kubernetes.

Install Minikube on Ubuntu 22.04 LTS

Minikube Installations 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

    For more info visit minikube official website

let’s walk through the process of installing Minikube on Ubuntu using Docker as the driver.

Update System Packages

ubuntu@RushiInfoTech:~$ sudo apt-get update

Step #1:Install Docker on Ubuntu 22.04 LTS

First, install Docker if it’s not already installed:

using below command install docker on ubuntu Ubuntu 22.04 LTS

ubuntu@RushiInfoTech:~$ sudo apt install -y docker.io

Once docker installed use the below command to check docker version

ubuntu@RushiInfoTech:~$ docker --version

Output:

Ensure Docker is running:

use the below command to start and enable docker service using systemctl

ubuntu@RushiInfoTech:~$ sudo systemctl start docker
ubuntu@RushiInfoTech:~$ sudo systemctl enable docker

To check docker service status use below command

ubuntu@RushiInfoTech:~$ sudo systemctl status docker

output:

ubuntu@RushiInfoTech:~$ docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
ubuntu@RushiInfoTech:~$ sudo systemctl start docker
ubuntu@RushiInfoTech:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-09-22 08:49:16 UTC; 5min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1934 (dockerd)
Tasks: 9
Memory: 27.3M
CPU: 333ms
CGroup: /system.slice/docker.service
└─1934 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Add the current user to the Docker group to run Docker commands without sudo. This step will also avoid certain permission issues when running Minikube:

ubuntu@RushiInfoTech:~$ sudo usermod -aG docker $USER
ubuntu@RushiInfoTech:~$ sudo newgrp docker

Step #2:Install Kubectl on Ubuntu 22.04 LTS

First, you need to download the Kubectl binary from the official Kubernetes release repository. To do this, run the following command in your terminal:

ubuntu@RushiInfoTech:~$ sudo  curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
ubuntu@RushiInfoTech:~$ sudo chmod +x kubectl
ubuntu@RushiInfoTech:~$ sudo mv kubectl /usr/local/bin/

Step #3:Install Minikube on Ubuntu 22.04 LTS

Fetch the latest Minikube binary and install it:

ubuntu@RushiInfoTech:~$ wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
ubuntu@RushiInfoTech:~$ chmod +x minikube-linux-amd64
ubuntu@RushiInfoTech:~$ sudo mv minikube-linux-amd64 /usr/local/bin/minikube

This will download the latest stable Kubectl binary from the repository. If you would like to download a specific version instead, you can specify the version in the download URL.

Step #4:Start Minikube with the Docker Driver

You can now start Minikube using Docker as the driver:

The Below command execution will take few minutes and This will initiate Minikube to start a single-node Kubernetes cluster inside a Docker container.

ubuntu@RushiInfoTech:~$ minikube start --driver=docker

Output as Expected below:

ubuntu@RushiInfoTech:~$ minikube start --driver=docker
* minikube v1.31.2 on Ubuntu 22.04 (xen/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.27.4 preload ...
    > preloaded-images-k8s-v18-v1...:  393.21 MiB / 393.21 MiB  100.00% 14.60 M
    > gcr.io/k8s-minikube/kicbase...:  447.62 MiB / 447.62 MiB  100.00% 14.09 M
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
  - 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

Screenshot:

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

Step #5: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:

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.

Related Articles:

How to Setup EKS Cluster using eksctl [6 Steps]

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *