Multi Node Kubernetes Cluster Using Ansible..

Multi Node Kubernetes Cluster Using Ansible..


What is a Kubernetes Cluster?

Kubernetes Cluster is a set of nodes that run containerized applications. Kubernetes clusters are comprised of one Master Node and a number of Worker Nodes. These nodes can either be physical computers or virtual machines, depending on the cluster.


Kubernetes Components:-

Control Plane Components:-

  • kube-apiserver - The API server is a component of the Kubernetes control plane that exposes the Kubernetes API.
  • etcd - Consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.
  • kube-scheduler - Control plane component that watches for newly created Pods with no assigned node, and selects a node for them to run on.
  • kube-controller-manager - Control Plane component that runs controller processes.

Node Components:-

  • kubelet - An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod.
  • kube-proxy - kube-proxy maintains network rules on nodes.
  • Container runtime - The container runtime is the software that is responsible for running containers. Ex - docker, CRI-O.


Let's Start the Practical Part:-

  • First of all, create a Seperate Workspace for writing the code.
mkdir /aws

cd /aws

  • Use cat command to read the Ansible Inventory and Ansible Configuration File.
No alt text provided for this image
  • Create a Key-Pair on AWS Cloud and then download it. Then transfer that key using WinSCP from Windows to the Virtual Machine where Ansible is configured. to the /aws folder. Then copy this key from /aws to /etc/ansible folder.
No alt text provided for this image
  • Provide the Permission to the Key-Pair for using it.
No alt text provided for this image
  • Then create a Ansible Playbook for launching two Instances on the top of AWS Cloud for configuring the Kubernetes Cluster.
vim ec2.yml


No alt text provided for this image
No alt text provided for this image
  • Create an Ansible Vault for keeping the AWS Access Key and Secret Key.
No alt text provided for this image
No alt text provided for this image
  • Now, if we will try to read the vault file using cat command, then we cannot read.
No alt text provided for this image
  • Use the command given below for reading the Ansible Vault. But, when we use this command, then it will first ask for Vault Password.
No alt text provided for this image
  • Now, before Running the Ansible Playbook, we have to check the syntax of the Playbook whether it is right or wrong.
No alt text provided for this image

Output:-

No alt text provided for this image
  • Check whether the Ansible Inventory is successfully updated or not.
No alt text provided for this image
  • Create an Ansible Role named as "Master" for Configuring Master Node.
No alt text provided for this image
  • Follow the steps to create an Ansible Playbook inside Master Role for configuring Master Node of Kubernetes Cluster.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
  • Create a file i.e. daemon.json inside the files folder of Master Role.
No alt text provided for this image
  • Create an Ansible Role named as "Slave" for Configuring Slave Node.
No alt text provided for this image
  • Follow the steps to create an Ansible Playbook inside Slave Role for configuring Slave Node of Kubernetes Cluster.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
  • Create a file i.e. daemon.json inside the files folder of Slave Role.
No alt text provided for this image
  • Create a file i.e. Cluster.yml for running both Master and Slave Roles for configuring Kubernetes Cluster.
No alt text provided for this image
  • Now, run the Ansible Playbook i.e. Cluster.yml by using the command given below.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


Successfully Done!! 😌😌


Now, to Verify that the Kubernetes Cluster is configured successfully -

  • Go to AWS, then select Master (EC2 Instance) and then click on Connect.
No alt text provided for this image
  • Change the power from ec2-user to root user and then use the command i.e. "kubectl get nodes" which shows that Master and Slave Node is in Ready State.
No alt text provided for this image


Hence, Kubernetes Cluster is Configured Successfully.😊😊


THANKS FOR GIVING YOUR VALUABLE TIME !!
😁😁


GITHUB REPO LINK:-


Tanumoy Deb

DevOps Engineer at SquareOps | ARTH Learner | AWS |

4y

Inspiring 😃

Himalaya Sahu

System Engineer at TCS Digital | 2 x RedHat Certified (RHCE) | Devops | Ansible l AWS l Kubernetes | Jenkins |

4y

Well explained 🔥🔥❤

To view or add a comment, sign in

More articles by Megha Varshney

  • How to Configure Web Server Inside the Docker Container by Retrieving Container's IP Dynamically Using Ansible Playbook?

    Task Description 📃:- 🔰Create an Ansible playbook that will retrieve new Container IP and update the inventory. So…

  • GUI Applications On The Top Of DOCKER

    What is Docker? Docker is an open source project that makes it easy to create containers and container-based apps. With…

  • Integration of WordPress with Amazon RDS:-

    What is AWS ? Amazon Web Services (AWS) is a secure cloud services platform, offering compute power, database storage…

  • What is Jenkins and How Netflix uses it?

    Hello guys, In this blog I’m going to explain the automation using Jenkins and a case study on Netflix. But before…

  • OpenShift and It's UseCases

    What is OpenShift ? OpenShift is a cloud development Platform as a Service (PaaS) developed by Red Hat. It’s an open…

  • Simple Queue Service by AWS

    What is SQS? SQS stands for Simple Queue Service. SQS is a managed message queue service offered by Amazon Web Services…

  • Neural Networks

    Neural Networks A Neural Network is a processing device, either an algorithm whose design is inspired by the design and…

  • Azure Kubernetes Service

    What is Azure Kubernetes Service? AKS stands for Azure Kubernetes Service provided by Azure Cloud. It is an open-source…

  • KUBERNETES USE CASES - AIRBNB And PINTEREST

    What is Kubernetes? KUBERNETES is a container management system developed in the Google platform. Kubernetes is the…

    2 Comments
  • THE SIMPLICITY OF ANSIBLE MEETS THE POWER OF AWS

    What is Ansible? Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration…

    2 Comments

Insights from the community

Others also viewed

Explore topics