Table of Contents

Choose a different version or distribution

Introduction

Before we get started, let's quickly define Minikube before discussing how to install Kubernetes with it on Ubuntu 22.04.

Minikube is a popular tool used for local development and testing of Kubernetes applications. It allows developers to run a single-node Kubernetes cluster on their own machine, providing an environment to deploy, manage, and interact with containerized applications.

With Minikube, developers can easily experiment with Kubernetes features, test their applications, and gain hands-on experience without the need for a full-scale production cluster. It's a valuable tool for those looking to learn, develop, and troubleshoot Kubernetes applications in a convenient and efficient manner.

In this tutorial, you will install Kubernetes with Minikube on Ubuntu 20.04. We will also address a few FAQs on how to install Kubernetes with Minikube on Ubuntu 20.04.

Advantages of Kubernetes

  1. Local Kubernetes Testing: Minikube enables developers to test Kubernetes applications locally, avoiding the need for a full-scale cluster.
  2. Easy Setup: It offers a simple and straightforward setup process, allowing developers to quickly create a single-node Kubernetes cluster on their own machine.
  3. Rapid Prototyping: Minikube facilitates fast prototyping by providing a local environment for developing and iterating on Kubernetes applications.
  4. Learning Tool: It serves as an excellent learning tool for developers to gain hands-on experience with Kubernetes without the complexities of a production environment.
  5. Compatibility: Minikube is compatible with various operating systems and can be used across different development environments, making it accessible and versatile for developers.

Prerequisites to Install Kubernetes

  • Ubuntu 20.04 desktop installed on your system
  • A root password set up on your system

Step 1 – Updating the system

1) Make sure that the system is running on the latest versions.

apt-get update -y
apt-get upgrade -y

2) Restart the computer to have the modifications take effect.

3) Then, download a few packages that would be useful.

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

Step 2 – Install VirtualBox Hypervisor

1) Since both KVM and VirtualBox Hypervisor are supported by Minikube, you can select which one to install. The following command can be used to install the VirtualBox Hypervisor:

apt-get install virtualbox virtualbox-ext-pack

Step 3 – Install Minikube

1) Download the latest version of Minikube with the help of the following command:

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

2) You need to copy the downloaded file to /usr/local/bin.

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

3) After that, give execution permission to Minikube.

chmod 755 /usr/local/bin/minikube

4) Then check the version of Minikube using the following command:

minikube version

5) You'll be able to see the following output:

minikube version: v0.34.1

Step 4 – Install Kubectl

1) Kubectl, a tool, is used to deploy and manage applications on Kubernetes. You must download them and add them to your system's repository because it is not included in the Ubuntu 20.04 repositories.

2) Download the GPG key, then add it.

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

3) Then, add Kubernetes apt repository with the following command:

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

4) Update the repository and install Kubectl.

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

5) You can then check the version of Kubectl installed with the help of the following command:

kubectl version -o json

6) You'll be seeing the following output:

Output
{
  "clientVersion": {
    "major": "1",
    "minor": "13",
    "gitVersion": "v1.13.4",
    "gitCommit": "c27b913fddd1a6c480c229191a087698aa92f0b1",
    "gitTreeState": "clean",
    "buildDate": "2019-02-28T13:37:52Z",
    "goVersion": "go1.11.5",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}

Step 5 – Start Minikube

1) Now, you can start the Minikube:

minikube start

2) The VirtualBox image will be downloaded, and the Kubernetes cluster will be set up as described below:

o   minikube v0.34.1 on linux (amd64)
>   Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
@   Downloading Minikube ISO ...
 184.30 MB / 184.30 MB [============================================] 100.00% 0s
-   "minikube" IP address is 192.168.99.100
-   Configuring Docker as the container runtime ...
-   Preparing Kubernetes environment ...
@   Downloading kubeadm v1.13.3
@   Downloading kubelet v1.13.3

-   Pulling images required by Kubernetes v1.13.3 ...
-   Launching Kubernetes v1.13.3 using kubeadm ... 
-   Configuring cluster permissions ...
-   Verifying component health .....
+   kubectl is now configured to use "minikube"
=   Done! Thank you for using minikube!

3) You may also check the status of the cluster:

kubectl cluster-info

4) After that, you will get output like below:

Output


Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

5) Additionally, you can examine the Kubectl default configuration:

kubectl config view

6) You will get output like below:

Output

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

7) The following command can be used to check the active nodes:

kubectl get nodes
Output

NAME       STATUS   ROLES    AGE     VERSION
minikube   Ready    master   2m45s   v1.13.3

8) You can then use Minikube VirtualBox:

minikube ssh

9) You will get an output like below:

Output

  _         _ ( )           ( )       ( )      
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

10) Exit the VirtualBox shell after that:

exit

11) Kubernetes clusters can even be stopped and deleted at any time:

minikube stop
minikube delete

12) Use this command to view Minikube's current status:

minikube status

13) You will get an output like below:

Output

host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

Step 6 – Access Kubernetes Dashboard

1) By default, Kubernetes comes with a web dashboard that you can use to control your cluster. All Minikube add-ons can be listed using:

minikube addons list

You will get an output like below:

Output

- addon-manager: enabled
- dashboard: disabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- gvisor: disabled
- heapster: disabled
- ingress: disabled
- logviewer: disabled
- metrics-server: disabled
- nvidia-driver-installer: disabled
- nvidia-gpu-device-plugin: disabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled
- storage-provisioner-gluster: disabled

2) Next, use the command below to list every running container image in the cluster:

kubectl get pods --all-namespaces

You will get the below output:

Output

NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
kube-system   coredns-86c58d9df4-76dkf               1/1     Running   0          4m30s
kube-system   coredns-86c58d9df4-wdtwb               1/1     Running   0          4m29s
kube-system   etcd-minikube                          1/1     Running   0          8m17s
kube-system   kube-addon-manager-minikube            1/1     Running   0          8m6s
kube-system   kube-apiserver-minikube                1/1     Running   1          8m13s
kube-system   kube-controller-manager-minikube       1/1     Running   1          8m13s
kube-system   kube-proxy-5k8qf                       1/1     Running   0          4m33s
kube-system   kube-scheduler-minikube                1/1     Running   0          8m2s
kube-system   kubernetes-dashboard-ccc79bfc9-z827s   1/1     Running   0          4m17s
kube-system   storage-provisioner                    1/1     Running   0          4m13s

3) Then, using the command below, you can obtain the Kubernetes dashboard's URL:

minikube dashboard --url

The result would look like this:

Output

-   Enabling dashboard ...
-   Verifying dashboard health ...
-   Launching proxy ...
-   Verifying proxy health ...
http://127.0.0.1:56508/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/

4) Paste the following URL into the address bar: http://127.0.0.1:56508/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your browser to arrive at the page displayed below:

Kubernetes Landing Page

FAQs to Install Kubernetes with Minikube on Ubuntu 20.04 LTS

What are the system requirements for running Minikube on Ubuntu?

To run Minikube on Ubuntu, you need a machine with at least 2 CPU cores, 2GB of RAM, and approximately 20GB of free disk space.

How can I verify the Minikube installation on Ubuntu?

After installing Minikube, you can open a terminal and run the minikube version command. It will display the installed Minikube version if the installation was successful.

Can I access the Minikube cluster using kubectl?

Yes, you can use the kubectl command-line tool to interact with the Minikube cluster. After starting the cluster, run kubectl cluster-info to verify the connection.

How can I stop or delete the Minikube cluster?

To stop the Minikube cluster, use the minikube stop command. If you want to delete the cluster completely, use minikube delete.

Can I use Minikube for production deployments?

Minikube is primarily intended for local development and testing. For production deployments, it's recommended to use full-scale Kubernetes clusters rather than Minikube.

Conclusion

We hope that this detailed tutorial helped you understand how to set up Minikube for Kubernetes on an Ubuntu 20.04 server. Visit the official Kubernetes installation document for further information on installing it on an Ubuntu 18.04 server.

Please leave a comment below if you have any questions, and we'll make sure to answer them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.