DEV Community

Abdenour ALIANE
Abdenour ALIANE

Posted on

Learn Kubernetes on your laptop with Minikube

First, let's be clear; future is containers !

This is a long debate, but as we asked in the past "Does it work on Windows or Linux", we will just ask "Does it work on Kubernetes" !

Cloud is here, Multi Cloud is here, Hybrid Cloud is here, and to make everything works in a "perfect" way, there is Kubernetes, there are tons of tutorials, on Youtube, on Google ,

Kubernetes is what orchestrates containers on clusters, it uses config files (yaml) where everything is perfect and tries to mimic this perfect world (state).

The architecture of Kubernetes needs some time to be understood, but to make stuff run (make hands dirty, then learn what made them dirty !), we can use Minikube, and of course there are alternatives, and tutorials too for each of them !

But this article will try to make two hits with one shot; use Minikube while you already have installed gcloud SDK

install sdk, right?

The installation will be made in a headless server Ubuntu 22.04 fresh minimal installation, Ubuntu uses Debian family commands, you can replace them with simple transitions if you are on Redhat family (yum/dnf instead of apt)

You can follow the instruction directly from the link, or, use the ones here :

First, let's download the SDK :

curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-410.0.0-linux-x86_64.tar.gz

download gcloud sdk

Then let's uncompress it

tar -xf google-cloud-cli-410.0.0-linux-x86_64.tar.gz

Then let's run the script :

./google-cloud-sdk/install.sh

And just follow the instructions by answering with one letter :

sorry i am lazy to do descriptions

As you can see, we need to re-run .bashrc file to enable the new inserted path, it will insert those two lines :

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/home/yourUserName/google-cloud-sdk/path.bash.inc' ]; then . '/home/yourUserName/google-cloud-sdk/path.bash.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/home/yourUserName/google-cloud-sdk/completion.bash.inc' ]; then . '/home/yourUserName/google-cloud-sdk/completion.bash.inc'; fi
Enter fullscreen mode Exit fullscreen mode

gcloud command

Then, each time we need to install a component we just need to run

gcloud components install SomeThing

That we already got its name from

gcloud components list

sorry i am lazy to do descriptions

sorry i am lazy to do descriptions

So, let's install minikube ^_^

sorry i am lazy to do descriptions

sorry i am lazy to do descriptions

To make minikube (our mini kubernetes) run, we just run minikube start

sorry i am lazy to do descriptions

But here is the catch; we need some hypervisor (Virtualbox, VMWare, KVM) or a container engine (Docker, Podman) to make it run, so we will install KVM as it's already available on Linux (think about Hyper-V on Windows)

The easiest way is to install Docker, but as we want to make something outside of Docker and make you discover 'new' stuff, let's make it differently

sudo apt update

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients

sorry i am lazy to do descriptions

As you can see, we need to do some security commands, as we don't want to run sudo here, so the trick is to add the user to the two groups, kvm and libvirt

sorry i am lazy to do descriptions

We need to restart to make it work.

And voilà !

*Hint : this is just a normal kvm virtual machine, this is the interface of Cockpit, the virt-manager alternative *

Image description

sorry i am lazy to do descriptions

But as you see, the main kubectl command that we find in every tutorial is missing, to solve this, we just need to run :

minikube kubectl

And it will download it

sorry i am lazy to do descriptions

Now, why we can't by default run kubectl, this is to not make conflict between the kubectl you install from the main Kubernetes installation, and minikube installation.

You can create an alias for this (you need to put the alias inside .bashrc to make it work eachtime you close the console):

sorry i am lazy to do descriptions

But you can still install kubectl using gcloud components install kubectl as this will allow you to use GKE too, and it works with minikube

sorry i am lazy to do descriptions

Here is a simple difference between both :

kubectl difference

Oh, you want to know what is GKE ?

gke

Now you can start practicing and creating what will be the future !

Top comments (0)