Learn Kubernetes on your laptop with Minikube
Abdenour ALIANE
Posted on November 28, 2022
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
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
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 :
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
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
So, let's install minikube ^_^
To make minikube (our mini kubernetes)
run, we just run minikube start
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
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
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 *
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
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):
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
Here is a simple difference between both :
Oh, you want to know what is GKE ?
Now you can start practicing and creating what will be the future !
Posted on November 28, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.