Creating and Managing a Kubernetes Cluster: A Practical Demo
There are various tools and methods available for creating and managing Kubernetes clusters. In this particular demonstration, I will be utilizing Kubeadm to create the Kubernetes cluster.
Minikube is a tool that enables developers to run a single-node Kubernetes cluster on their local machine. It provides an easy way to test and experiment with Kubernetes without having to set up a full production cluster. Minikube runs Kubernetes within a virtual machine and includes features such as automatic node provisioning, dashboard access, and support for various Kubernetes add-ons. It's a popular tool for developers who want to learn and experiment with Kubernetes in a local environment.
Kubeadm is a popular tool for bootstrapping a Kubernetes cluster. It provides a simple and flexible way to set up a production-ready cluster on various infrastructure platforms, including cloud providers and on-premise data centers. Kubeadm automates many of the complex tasks involved in setting up the control plane and worker nodes, such as generating certificates and setting up network connectivity. It also supports various configuration options and add-ons, allowing users to customize their clusters according to their specific needs. Kubeadm is widely used in production environments and is recommended by the official Kubernetes documentation as a reliable way to set up a cluster.
Managed k8s cluster on cloud EKS, AKS, and GKE are managed Kubernetes services provided by Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP), respectively. These services make it easy for users to deploy and manage Kubernetes clusters on their respective cloud platforms.
KIND (Kubernetes in Docker) is a tool that allows users to create Kubernetes clusters using Docker containers. It provides a lightweight and portable way to create and run Kubernetes clusters locally, making it ideal for testing and development purposes. KIND also supports integration with other Kubernetes tools such as kubectl and Helm, making it easy to deploy and manage applications on the cluster. It provides features such as automatic load balancing, rolling updates, and container runtime support, making it a powerful tool for testing and development.
Creating K8s Cluster
Step 1: Create 2 EC2 Instances with the below configuration.

Step 2: Name one Instance as the Master server and the other one as Worker. Master Server has yellow color fonts and the worker server has green color fonts.
Step 3: We need to update the local package database which is apt on both servers. Use apt-get update command for the same.
Step 4: Next, We need to install docker on both servers using apt-get install docker.io command.


Step 5: Run the below commands to start the docker services on both nodes.
systemctl start docker
systemctl enable docker


Step 6: To Install Kubectl, Kubeadm and Kuebelet use the below commands, we can install all three on both nodes, and there is no conflict here.
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update -y sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y


Step 7: Commands need to be executed on the Master node only.
sudo su
kubeadm init
mkdir -p $HOME/.kubecp -i /etc/kubernetes/admin.conf $HOME/.kube/configchown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml ---> Network connectivity will be created if you execute this.
kubeadm token create --print-join-command

Step 8: Commands need to be executed on the Worker node only.
sudo su kubeadm reset pre-flight checks

Copy the output of the below command from the Master node and add --v=5 at the end of the file.kubeadm token create --print-join-commandNote: You need to allow the port in the Security Group attached to the EC2 instance as per the command output.


After running these commands, run the below command on the Master node. You can see two nodes are attached to the cluster.
kubectl get nodes

Deploying an Nginx server
Step 1: Run the below command to create an Nginx pod.
kubectl run nginx --image=nginx

Step 2: Check the worker node and run docker ps command. The screenshot has docker ps command's o/p before and after creating the pod.

Step 3: I purposely deleted the docker container in the worker node, as we are managing the containers using the K8s cluster it is auto-healed and created another container.

In the Master Node, the Pod's Restarts column is showing 1 as the pod restarted due to another docker nginx container being created after we killed the nginx container.



Check out the below article for more information on Kubeadm