Cluster in Containers

“Kubernetes in Docker” the Hard Way

Self Configured KinD Cluster

Manas Peçenek
adessoTurkey

--

github.com/ManasPecenek/clinco

Kubernetes is an awesome tool to deploy your application. It is nearly a must nowadays to be skilled at it. However, is everybody familiar with the Kubernetes internals or how to install a cluster from scratch?

Here comes “Kubernetes the Hard Way” by Kelsey Hightower. As you may have already known, in his repository “Kubernetes the Hard Way” a Kubernetes cluster is installed from scratch on VMs. After spending some time on this repository, I decided to install a Kubernetes Cluster from scratch inside Docker Containers.

In this article, I will briefly demonstrate how to create a Kubernetes Cluster inside Docker Containers. If you want to take a look at the details, you can check my GitHub repository.

How to Create a Cluster

Download the scripts:

git clone --depth=1 https://github.com/ManasPecenek/clinco.git && cd clinco && chmod +x initial-script.sh add-worker.sh && alias startCluster="bash initial-script.sh" addNode="bash add-worker.sh"

For simplicity, you can set KUBECONFIG environment variable:

export KUBECONFIG=./admin.kubeconfig

Now run the script with how many worker nodes you want. For example “startCluster -n 3” will result in a 3-worker-node cluster:

startCluster -n <worker-node-count>

If you do not specify a number and run startCluster, it will only create a 1-worker-node cluster.

How to Add Additional Worker Nodes to the Cluster

Run the script below. For example running “addNode -n 4” will add four worker nodes to the existing cluster:

addNode -n <worker-node-count>

If you do not specify a number and run addNode, it will add 1 node to your cluster.

Checking the Cluster

Run “startCluster 4” for testing and then:

docker ps
kubectl cluster-info
kubectl get nodes -o wide
kubectl create deploy nginx --image nginx --replicas 4kubectl get pods -o wide

Resources:

--

--