Kubernetes: from experimenting with Minikube to AKS (Part 1)

Raphael Gab-Momoh
Azure Nigeria Community Group
5 min readSep 4, 2022

--

The objective of this article is to help community members eliminate the fear of getting started with Kubernetes. This article is going to be a three parts series. In the first part, we shall be looking at how to set up Minikube in your local environment along with a few examples to show that Kubernetes is up and running. After that, we are ready to work with Kubernetes locally in part 2, we shall be deploying a sample Kubernetes application. Finally, in the last part of the series, we shall focus on how to deploy a sample application with Azure Kubernetes Service.

Setting up Minikube for local development

A very simple Kubernetes cluster setup can be accomplished using the application Minikube. Learning Kubernetes and creating goods and applications is easy to do with Minikube.

Requirements

You must give the following resources to Minikube on your system in order for Kubernetes to operate correctly.

  • 2 CPUs or higher
  • 2 GB of memory
  • 20 GB or more of free disk space
  • Reliable internet connection.
  • Container or virtual machine driver or manager such as Docker, KVM, Podman, and Virtual Box, amongst others.

We shall be installing Ubuntu 22.04 on VMware workstation pro. You can get a copy of VMware workstation pro here: Vmware workstation P. You can get a copy of Ubuntu 22.04 here: https://ubuntu.com/d

Step1: Update your package index

package index can be updated with the command:

sudo apt update
package index update

Step2: Install Virtualbox driver

The original driver for Minikube is VirtualBox.There are quite a few options to choose from here including KVM and docker. It can be installed with the command:

sudo apt install virtualbox virtualbox-dkms virtualbox-qt virtualbox-ext-pack
package config

To accept the VirtualBox Extension Pack license, select Yes and press Enter.

accept license

Finally downloaded

virtual box driver downloaded

Step2a: Install docker

Since we will be running Minikube within a Vm it would make sense to have docker installed but if you have enabled virtualization in your bios you can choose not to install it because you can choose to use VirtualBox. So, install docker and use the flag when running minikube — — driver=docker

sudo apt install docker.io

After installing docker run the following commands:

systemctl enable docker
systemctl start docker
systemctl status docker

finally, for docker, add your login user to the docker group with the following command:

sudo usermod -aG docker $USER && newgrp docker

Step2b: Enable Virtualization of Hardware if necessary

You can use the command to check if your virtualization is enabled or not and enable it from the bios if it’s not, but to save you all the stress, you can choose to use docker as your driver instead of VirtualBox

lscpu | grep Virtualization

Step3: Download Minikube

Using the Debian package, install the most recent minikube stable release on x86–64 Linux with the command:

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
minikube downloaded

We can verify the version downloaded with the command:

minikube version
minkube version

Step4: install Kubectl on Ubuntu

To deploy and manage apps on Kubernetes, we require kubectl, a command-line tool that we can install with the command:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
kubectl

Ensure that it is executable

chmod +x ./kubectl

The binary should now be in your PATH:

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

verify the kubectl that you have downloaded

kubectl version -o json  --client
kubectl version

Step 4: Start Minikube

minikube start --driver=docker
minikube configured!

From the screenshot above, we can see that minikube created a Kubernetes cluster for us, we can inspect this by using the command:

kubectl get nodes
k8s get nodes

Next, let's create a deployment and call the name =azurenaija and image= nginx with a tag of latest

kubectl create deployment azurenaija --image=nginx:latest
azurenaija deployment

As you can see a new deployment called azurenaija was created. But we can officially verify this with the command:

kubectl get deployments
ready

Next, let's expose the service for our azurenaija deployment with these commands:

kubectl expose deployment azurenaija --type=NodePort --port=8080
azurenaija exposed

We can also get the service using the command

kubectl get service
get service

Now let's delete the deployment and also the service

kubectl delete deployment azurenaija
delete deployment
kubectl delete service azurenaija
delete service

We can stop minikube with the command:

minikube stop
minikube stop

Summary

I’ve demonstrated how to set up Minikube and the Kubernetes command-line tool kubectl on Ubuntu 22.0. In this article, we set up a local Kubernetes cluster with Minikube using the Docker driver on Ubuntu 22.04 LTS. Additionally, I created a service and a deployment for you to use on your computer to demonstrate the fundamentals of utilizing Kubernetes. You should be able to use Kubernetes and Minikube now.

--

--

Raphael Gab-Momoh
Azure Nigeria Community Group

Experienced Cloud Engineer with a demonstrated history of working in the information technology and services industry.