Learn Kubernetes on your laptop with Minikube
Published: 2022-11-28 16:59:35

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](https://www.youtube.com/results?search_query=kubernetes+101), on [Google](https://www.google.com/search?q=kubernetes+tutorials) ,

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](https://minikube.sigs.k8s.io/), and of course there are [alternatives](https://www.google.com/search?q=minikube+vs+microk8s+vs+k3s), 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](https://cloud.google.com/sdk/docs/install)


![install sdk, right?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a2yz2ppmqfli5jzajsdc.jpeg)

**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](https://cloud.google.com/sdk/docs/install), 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rulwztijgeie56dm4o3.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qx2vziqsyqraew7hml7y.png)


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
```

![gcloud command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9ivmtfc8jredeyy4eba.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5cr7wwcp3u4ydkm22uw.png)


![sorry i am lazy to do descriptions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fndou25uxes93i51q4qo.png)

So, let's install **minikube** ^_^

![sorry i am lazy to do descriptions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3ao87xekaq66aqqhgjb.png)


![sorry i am lazy to do descriptions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p387829ukn92orsjynw2.png)

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

![sorry i am lazy to do descriptions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2uqf7epuu61o1hnji8em.png)

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](https://docs.docker.com/engine/install/ubuntu/), 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9xxkv13a6tforc9i527.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aryna3lvq0giktqnjumn.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfveod379xn1gstpzkun.png)


![sorry i am lazy to do descriptions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oxc2h43iglwetw87s0ey.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vco0jevwagmiwij4ibdq.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7ouab8gx0z6dd7bqevi.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5129lwfq8b97r6dgk0g.png)

Here is a simple difference between both :


![kubectl difference](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2tai4d1mimf4m2x4cuy.png)

Oh, you want to know what is GKE ?

![gke](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q34errspt0nates4h39i.jpeg)

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