Setup a 'sane' K8s cluster in local env using KinD
Are you still using Minikube in 2020 to provision your local Kubernetes environment?
Don’t you love the idea of having a multi-Node cluster for your local env too?
Idea of having Docker Containers as “Nodes”? Pre-installed binaries and tools to test, debug and understand the wizardry of K8s.
If all of the above is intriguing you then we’re cool and ready to learn
more about this amazing tool called KinD
(Kubernetes in Docker 😊).
Without much ado, let’s staaart!
Installation
On *NIX like machine:
|
|
For installation on other OSs and more see this
Creating cluster
Creating cluster on KinD is as easy as $ kind create cluster
but wait! don’t get
excited as this command will bootstrap the cluster using default settings
like single node cluster, “kind” as cluster’s context name, etc which we surely want to avoid if we
need a sane cluster.
Trivia: As we already know that KinD
uses docker containers as “Nodes” therefore
by default it uses its custom Node Image for creating “Nodes”.
|
|
Deploying app
If all goes well, then we will see that our cluster is setup properly. Now it’s time to deploy apps onto this freshly created cluster. Yay!, let’s do it.
|
|
And it’s done.
Tip: - To go inside a “Node” just do
$ docker exec -it foo-bar-worker2 bash
and boom, you’re inside a worker node.
Okay Okay, now this’s cool but what else KinD
has to offer?
Apart from setting up a multi-node cluster using Docker containers as “Nodes”,
which is something very cool mind you, KinD
has few other things to offer as a tool.
After SSHing/entering in one of your nodes, it has several tools installed for
debugging and playing with Kubernetes itself such as crictl
, iptables-save
,
etc. These binaries are installed by default which IMO are very much needed when you want to go
real deep into kubernetes, and curious to know how things are
working under the hood to provide you such a seamless orchestration.
To learn more about crictl see https://kubernetes.io/docs/tasks/debug-application-cluster/crictl/ and same goes for other kubernetes resources and tools.
Although, managing infrastructure using YMLs is new fad! but when it comes to debugging an issue then shit goes real and you have to have these concepts known to you beforehand in order to actually start a debugging session otherwise you’ll be lost.
Conclusion
Although Minikube has served humanity very well ;-p, but KinD
is superior
alternative to it for provisioning local k8s cluster with multi-node setup. IMO, Docker containers as
“Nodes” is itself a very creative idea and it also makes sense and seems quite sane to me in
the era where containers are first class citizens.
For complete documentation on KinD
visit: https://kind.sigs.k8s.io/
Finally, to clean everything type $ kind delete cluster
#TillThenHappyCoding