Manage your personnel kubernetes cluster with this tool

Everton Segur
2 min readAug 24, 2021

In this post I want to bring you a little bit about the kubernetes cluster tool called Kind.

At some point, you and I will want to replicate our cloud environment that uses kubernetes, that’s for sure. However, how can I perform this task in a simple and practical way and still using a service that is easy to manage?

I present Kind, this cli that opens the doors of happiness to have our own kubernetes cluster locally.

As a prerequisite, it is necessary to install docker and kubectl to access the kubernetes cluster later.

The installation of services follows below:

After performing the installation, we will now install the kubernetes cluster.

sudo chown $(whoami) /var/run/docker.sock
sudo curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
sudo chmod +x ./kind
sudo mv ./kind /usr/bin/kind

Creating a new cluster is also quick:

kind create cluster

Since we now have our cluster available, let’s deploy a hello-world pod for testing.

kubectl run hello-kubernetes --rm --tty -i --restart='Never' --namespace default --image docker.io/hello-world:latest

After performing the test and validating the operation, we will configure the exposure of the next services that will be made available in the cluster.

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/master/manifests/namespace.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/master/manifests/metallb.yaml
kubectl apply -f https://kind.sigs.k8s.io/examples/loadbalancer/metallb-configmap.yaml

These settings are responsible for always providing an accessible external ip and a respective port when exposed by the kubernetes services.

Now we will enable the communication route from the network interface to the kubernetes service, as this makes access easier.

sudo ip route add 172.19.0.0/16 via $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' kind-control-plane)

Let’s test?

Deployment creation:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/service/networking/run-my-nginx.yaml
kubectl get pods -l run=my-nginx -o wide

Service creation:

kubectl expose deployment/my-nginx --type=LoadBalancer
kubectl get svc my-nginx -o wide

Now the test:

curl 172.19.255.200:80

Got been tired? Erase everything:

kind delete cluster

A little more

To import your docker images into kind use this syntax:

kind load docker-image your-docker-image-name:desired-version

About me

I am currently a Java developer at ZUP IT, a company that develops several market tools that help devs and infra staff. I have a background focused on infrastructure, you can follow me on linkedin

--

--