Create an easy kubernetes cluster using kind and docker on your workstation
Assuming that you want to have a quick way to spawn up a kubernetes cluster for some development work all you need to do is to have docker desktop installed and install kind app on your computer. I will not go through the installation process as it is very well described in here.
Once you have docker up and running and kind installed all you need to do is to open up your terminal and run the following:
#kind create cluster --name <some name>
Creating cluster "<some name>" ...
â Ensuring node image (kindest/node:v1.21.1) đŧ
â Preparing nodes đĻ
â Writing configuration đ
â Starting control-plane đšī¸
â Installing CNI đ
â Installing StorageClass đž
Set kubectl context to "kind-<some name>"
You can now use your cluster with:
kubectl cluster-info --context kind-<some name>
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community đ
Few minutes later your kubernetes cluster is up and running and you can start working. However this will create you only a single node cluster that has one control-plane node. You can activate it by using the command from the output of the cluster creation command. The output will look something like this:
#kubectl cluster-info --context kind-<some name>
Kubernetes control plane is running at https://127.0.0.1:64000
CoreDNS is running at https://127.0.0.1:64000/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
After this you can list the nodes:
#kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
<some name>-control-plane Ready control-plane,master 6m45s v1.21.1 172.19.0.6 <none> Ubuntu 21.04 5.10.76-linuxkit containerd://1.5.2
If you want a bit more complex installation then we need to create a simple config file in YAML format that will look like this:
#cat cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: test
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
This will create a 4 node cluster with one control-plane node and 3 worker nodes.
Now we can deploy the cluster by running the following command:
#kind create cluster --config cluster.yaml
Creating cluster "test" ...
â Ensuring node image (kindest/node:v1.21.1) đŧ
â Preparing nodes đĻ đĻ đĻ đĻ
â Writing configuration đ
â Starting control-plane đšī¸
â Installing CNI đ
â Installing StorageClass đž
â Joining worker nodes đ
Set kubectl context to "kind-test"
You can now use your cluster with:
kubectl cluster-info --context kind-test
Have a nice day! đ
Now the cluster is ready to be used. If you are checking the cluster you will see that this time you have a 4 node cluster up and running.
#kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
test-control-plane Ready control-plane,master 2m36s v1.21.1 172.19.0.10 <none> Ubuntu 21.04 5.10.76-linuxkit containerd://1.5.2
test-worker Ready <none> 119s v1.21.1 172.19.0.7 <none> Ubuntu 21.04 5.10.76-linuxkit containerd://1.5.2
test-worker2 Ready <none> 119s v1.21.1 172.19.0.9 <none> Ubuntu 21.04 5.10.76-linuxkit containerd://1.5.2
test-worker3 Ready <none> 116s v1.21.1 172.19.0.8 <none> Ubuntu 21.04 5.10.76-linuxkit containerd://1.5.2
Note: To be able to interface with the cluster you will have to install the cli tools like kubectl and helm and many others that you will want to use.