Kubernetes is an open source system to deploy, scale and manage containerized applications anywhere.
You can choose to install it locally on your host machine or use it via a cloud provider such as GCP and AWS.
Using Kubernetes via a cloud provider is usually the best option, but you can also choose to run it locally.
Installing it on your local machine is not a hassle at all but could be tricky at times. We would be digging deep and exploring all our options.
INSTALLING ON A MAC
To install kubernetes on a mac you should install a lightweight virtual machine first called hyperkit. Preferably use brew for your installation
brew install hyperkit
brew install minikube
If you have an older version of minikube with a virtual machine it is best to uninstall that first with
minikube delete
then reinstall afresh
brew install hyperkit
brew install minikube
to start the minikube cluster you need to point minikube to the vm - hyperkit
minikube start --vm-driver=hyperkit
Please note that during installation minikube installed kubectl as a dependency.
when all is done, you can check their versions for confirmation
kubectl version
minikube version
minikube status
kubectl get nodes
INSTALLING ON A LINUX MACHINE
Installing kubernetes on a linux machine you first need to update the machine with
sudo apt update
then install a virtual machine that kubernetes will run on preferably a lightweight vm
sudo apt update
sudo apt install virtualbox
or if you prefer qemu-kvm virtual machine
sudo apt update
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system
When installation is complete, the next step is to install kubectl
sudo apt update
sudo apt install kubectl
OR
snap install kubectl --classic
Then finally you install minikube by installing its binary
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
When installation is complete, to start the cluster you should point minikube to the virtual machine installed
For VirtualBox
minikube start --driver=virtualbox
For KVM/QEMU
minikube start --driver=kvm2
minikube status
kubectl get nodes
INSTALLING ON A LINUX MACHINE RUNNING ON A VIRTUAL MACHINE
Most times this is usually the trickiest part, running a linux machine on a VM and you need yet another vm to run kubernetes, thats the analogy right? but yes and no.
You see actually you need nested virtualization for this, thats a vm on another vm but one thing to note here is that docker can integrate so well with kubernetes so instead of using a vm on another vm we can use docker to serve as the driver hence no need for that vm. So how do we do this
sudo apt update
sudo apt install docker.io
docker version
systemctl start docker
systemctl status docker
ctrl + c to return
snap install kubectl --classic
Next step install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube version
Now point minikube to docker like this
minikube start --driver=docker
This would raise an alarm, so add your user to the docker group to give it permission. Add it like this
sudo usermod -aG docker $USER && newgrp docker
Run the command to start the minikube cluster
minikube start --driver=docker
Note: ensure docker has space enough space and is not cluttered, to prune docker run
docker system prune -f
Confirm install
kubectl version
minikube version
minikube status
Start
kubectl get nodes
Voila kubernetes is now up running !!!
Top comments (1)
The post is a great resource for beginners who want to learn how to install Kubernetes on their local machine.
Is it possible to install minikube on Windows?