How to Install Kubernetes with Minikube on Ubuntu 20.04

Minikube is an open-source tool that helps you to set up a single-node Kubernetes cluster on your local machine. It makes it easy to run a single node Kubernetes cluster on your personal computer for daily development work. It is cross-platform and can be installed on macOS, Linux, and Windows.

In this tutorial, we will show you how to install Minikube on Ubuntu 20.04 server.

Prerequisites

  • Ubuntu 20.04 desktop installed in your system.
  • Minimum 4 GB of RAM and 2 or more CPU core.
  • Hardware virtualization must be enabled in your local system.
  • A root password is configured the server.

Getting Started

Before starting, it is recommended to update your system packages to the latest version. You can update them by running the following command:

apt-get update -y

Once all the packages are updated, install other dependencies by running the following command:

apt-get install curl wget apt-transport-https virtualbox virtualbox-ext-pack -y

Once you are finished, you can proceed to the next step.

Install Docker

Next, you will need to install Docker to your system. You can install it by running the following command:

apt-get install docker.io -y

Once the Docker is installed, start the Docker service and enable it to start at system reboot:

systemctl start docker
systemctl enable docker

You can now verify the Docker version using the following command:

docker --version

You should see the Docker version in the following output:

Docker version 19.03.8, build afacb8b7f0

Once you are finished, you can proceed to the next step.

Install Minikube

By default, Minikube is not available in the Ubuntu default repository. So you will need to download the Minikube binary package from its official website. You can download it with the following command:

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

Once the download is completed, copy the downloaded binary to the system path using the following command:

cp minikube-linux-amd64 /usr/local/bin/minikube

Next, provide execution permission with the following command:

chmod 755 /usr/local/bin/minikube

You can now verify the Minikube version with the following command:

minikube version

You should get the following output:

minikube version: v1.16.0
commit: 9f1e482427589ff8451c4723b6ba53bb9742fbb1

Once you are finished, you can proceed to the next step.

Install Kubectl

Next, you will need to install Kubectl and other tools to manage applications on Kubernetes. First, add the GPG key with the following command:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

Next, add the kubectl repository with the following command:

echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list

Once the repository is added, update the repository cache and install the Kubectl by running the following command:

apt-get update -y
apt-get install kubectl kubeadm kubectl -y

Once all the packages are installed, you can proceed to the next step.

Start Minikube

At this point, all required packages are installed. You can now start Minikube with the following command:

minikube start

You should get the following output:

* minikube v1.16.0 on Ubuntu 20.04 (kvm/amd64)
* Using the none driver based on user configuration
* Starting control plane node minikube in cluster minikube
* Running on localhost (CPUs=2, Memory=3936MB, Disk=100726MB) ...
* OS release is Ubuntu 20.04 LTS
* Preparing Kubernetes v1.20.0 on Docker 19.03.8 ...
  - kubelet.resolv-conf=/run/systemd/resolve/resolv.conf
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 37.40 MiB / 37.40 MiB [---------------] 100.00% 27.29 MiB p/s 1s
    > kubectl: 38.37 MiB / 38.37 MiB [---------------] 100.00% 27.60 MiB p/s 1s
    > kubelet: 108.69 MiB / 108.69 MiB [-------------] 100.00% 42.08 MiB p/s 3s
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring local host environment ...
* 
! The 'none' driver is designed for experts who need to integrate with an existing VM
* Most users should use the newer 'docker' driver instead, which does not require root!
* For more information, see: https://minikube.sigs.k8s.io/docs/reference/drivers/none/
* 
! kubectl and minikube configuration will be stored in /root
! To use kubectl or minikube commands as your own user, you may need to relocate them. For example, to overwrite your own settings, run:
* 
  - sudo mv /root/.kube /root/.minikube $HOME
  - sudo chown -R $USER $HOME/.kube $HOME/.minikube
* 
* This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
* Verifying Kubernetes components...
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

You can check the cluster information with the following command:

kubectl cluster-info

You should get the following output:

Kubernetes control plane is running at https://45.58.38.77:8443
KubeDNS is running at https://45.58.38.77:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

You can check the Kubectl default configuration with the following command:

kubectl config view

You should see the following output:

apiVersion: v1
clusters:
- cluster:
    certificate-authority: /root/.minikube/ca.crt
    server: https://45.58.38.77:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /root/.minikube/profiles/minikube/client.crt
    client-key: /root/.minikube/profiles/minikube/client.key

You can check all the running nodes with the following command:

kubectl get nodes

You should get the following output:

NAME         STATUS   ROLES                  AGE     VERSION
ubuntu2004   Ready    control-plane,master   2m24s   v1.20.0

To verify the status of Minikube, run the following command:

minikube status

You should get the following output:

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
timeToStop: Nonexistent

Once you are finished, you can proceed to the next step.

Access Kubernetes Dashboard

Minikube comes with a lot of addons that you can enable or disable as per your needs. You can list all addons with the following command:

minikube addons list

You should get the following output:

|-----------------------------|----------|--------------|
|         ADDON NAME          | PROFILE  |    STATUS    |
|-----------------------------|----------|--------------|
| ambassador                  | minikube | disabled     |
| csi-hostpath-driver         | minikube | disabled     |
| dashboard                   | minikube | disabled     |
| default-storageclass        | minikube | enabled ?   |
| efk                         | minikube | disabled     |
| freshpod                    | minikube | disabled     |
| gcp-auth                    | minikube | disabled     |
| gvisor                      | minikube | disabled     |
| helm-tiller                 | minikube | disabled     |
| ingress                     | minikube | disabled     |
| ingress-dns                 | minikube | disabled     |
| istio                       | minikube | disabled     |
| istio-provisioner           | minikube | disabled     |
| kubevirt                    | minikube | disabled     |
| logviewer                   | minikube | disabled     |
| metallb                     | minikube | disabled     |
| metrics-server              | minikube | disabled     |
| nvidia-driver-installer     | minikube | disabled     |
| nvidia-gpu-device-plugin    | minikube | disabled     |
| olm                         | minikube | disabled     |
| pod-security-policy         | minikube | disabled     |
| registry                    | minikube | disabled     |
| registry-aliases            | minikube | disabled     |
| registry-creds              | minikube | disabled     |
| storage-provisioner         | minikube | enabled ?   |
| storage-provisioner-gluster | minikube | disabled     |
| volumesnapshots             | minikube | disabled     |
|-----------------------------|----------|--------------|

Next, list all the container image running in the cluster with the following command:

kubectl get pods --all-namespaces

You should get the following output:

NAMESPACE     NAME                                 READY   STATUS    RESTARTS   AGE
kube-system   coredns-74ff55c5b-skf9d              1/1     Running   0          3m45s
kube-system   etcd-ubuntu2004                      1/1     Running   0          3m54s
kube-system   kube-apiserver-ubuntu2004            1/1     Running   0          3m54s
kube-system   kube-controller-manager-ubuntu2004   1/1     Running   0          3m54s
kube-system   kube-proxy-w8q6d                     1/1     Running   0          3m45s
kube-system   kube-scheduler-ubuntu2004            1/1     Running   0          3m54s
kube-system   storage-provisioner                  1/1     Running   0          3m59s

Next, enable the Kubernetes dashboard and get the URL of the dashboard with the following command:

minikube dashboard --url

You should get the following output:

* Enabling dashboard ...
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:36499/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

You can now access and manage the Kubernetes cluster using the URL http://127.0.0.1:36499/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

Conclusion

In the above guide, you learned how to install Minikube and use it to set up a Kubernetes cluster on Ubuntu 20.04. You can now use Minikube to set up Kubernetes cluster locally and manage it from the web browser. Feel free to ask me if you have any questions.

Share this page:

2 Comment(s)