Friday, March 29, 2024
Google search engine
HomeDevOpsHow to Install Minikube on Ubuntu 20.04 / 21.04

How to Install Minikube on Ubuntu 20.04 / 21.04

Minikube is an open source tool that allows you to set up a single-node Kubernetes cluster on your local machine. The cluster is run inside a virtual machine and includes Docker, allowing you to run containers inside the node. below this tutorial how to install minikube on ubuntu

This is an excellent way to test in a Kubernetes environment locally, without using up too much resources.

In this article we will cover the installation of Minikube on Ubuntu 20.04 / 21.04.

Minimum system requirements for minikube

Minikube supports Kubernetes features such as:

  • DNS
  • NodePorts
  • ConfigMaps and Secrets
  • Dashboards
  • Container Runtime: Docker, CRI-O, and containerd
  • Enabling CNI (Container Network Interface)
  • Ingress
  • PersistentVolumes of type hostPath

Note: In this article, I will be using Docker container as a base for minikube. In case, docker is not installed on your ubuntu system then use following URL to install it.

Prerequisites for minikube

  • Minimal Ubuntu 20.04 LTS (I'm using VPS with KVM)
  • SUDO User with root privileges
  • Stable Internet Connection

Apply updates

Update and upgrade your ubuntu by executing the following apt commands

sudo apt update -y && sudo apt upgrade -y

I suggest to reboot your system after update

Install Minikube dependencies

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

Download Minikube Binary

Use wget command to download latest minikube binary

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

Confirm version installed

$ minikube version
minikube version: v1.22.0
commit: a03fbcf166e6f74ef224d4a63be4277d01xxxxxx

Install kubectl on Ubuntu / Debian

We need kubectl which is a command line tool used to deploy and manage applications on Kubernetes. Use below curl command to download latest version of kubectl

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
$ sudo mv kubectl /usr/local/bin/

and then Check version:

$ kubectl version -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "22",
    "gitVersion": "v1.22.1",
    "gitCommit": "632ed300f2c34f6d6d15ca4cef3d3c7073412212",
    "gitTreeState": "clean",
    "buildDate": "2021-08-19T15:45:37Z",
    "goVersion": "go1.16.7",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Starting minikube

if you run with user (non root), please add the user to group with

sudo usermod -aG docker <youruser> && newgrp docker

Now that components are installed, you can start minikube. your server will be downloaded and configure d for Kubernetes single node cluster.

minikube start --driver=docker
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
150.53 MB / 150.53 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Finished Downloading kubelet v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

and wait for the minutes your server will download and setup to finish then confirm that everything is working well.

$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Minikube Basic operations

$ kubectl cluster-info
Kubernetes control plane is running at https://192.168.38.111:8443
CoreDNS is running at https://192.168.38.111:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

just for note: Minikube configuration file is located under ~/.minikube/machines/minikube/config.json

or you can verify with

$ kubectl cluster-info
$ kubectl get nodes

To View Config, use:

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/harz/.minikube/ca.crt
    extensions:
    - extension:
        last-update: Mon, 30 Aug 2021 14:11:18 UTC
        provider: minikube.sigs.k8s.io
        version: v1.22.0
      name: cluster_info
    server: https://192.168.38.111:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Mon, 30 Aug 2021 14:11:18 UTC
        provider: minikube.sigs.k8s.io
        version: v1.22.0
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/devninja/.minikube/profiles/minikube/client.crt
    client-key: /home/devninja/.minikube/profiles/minikube/client.key

To check running nodes:

$ kubectl get nodes
NAME       STATUS   ROLES                  AGE   VERSION
minikube   Ready    control-plane,master   21h   v1.21.2

Managing Addons on minikube

Kubernete ships with a web dashboard which allows you to manage your cluster without interacting with a command line. to see the addons of minikube, run the below command

minikube addons list

How to Install Minikube on Ubuntu
If you want to enable any addons run the below minikube command

minikube dashboard

To get the URL of the dashboard

minikube dashboard --url
http://192.168.38.111:30000

Managing Minikube Cluster

To stop the minikube, run

$ minikube stop

To delete the minikube, run

$ minikube delete

To Start the minikube, run

$ minikube start

In case you want to start the minikube with higher resource like 8 GB RM and 4 CPU then execute following commands one after the another.

$ minikube config set cpus 4
$ minikube config set memory 8192
$ minikube delete
$ minikube start

That’s all from this tutorial, I hope you have learned how to install Minikube on Ubuntu 20.04 / 21.04 system.

YOU CAN SUPPORT DEVNINJA WITH A CUP OF COFFEE

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online. to search or browse the published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or more ) as a token of appreciation.

Support Us

DevNinja
DevNinja
System & Network Administrator Ninja
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

8 − one =

- Advertisment -
Google search engine

Most Popular

Recent Comments