Kubernetes Multi-Node Cluster on AWS Using Ansible

Surayya Shaikh
3 min readMar 29, 2021

--

K8s-Cluster-AWS-Ansible

In this article, I will show you how we can launch Kubernetes multi-node cluster on AWS cloud using the Ansible automation tool.

  • First of all why we need a multi-node cluster?

Because we have different programs/resources in a node to monitor pods, but what if your node itself goes down or crashes, then all the system pods will also fail, So in this case, you will face a single point of failure (SPOF).

So, it is recommended to use multiple nodes, Generally, we have master and slave nodes. Master has control over slave nodes.

  • KCM (Kubernetes Controller Manager)

This program will keep on checking worker nodes' health and if the node goes down then KCM will ask the Replication Controller to launch the node again.

  • Kubelet is a program that will be running in each node and will be replying to KCM and then KCM will get the status. Kubelet lies in between master and slaves.

Below are steps to create a k8s multi-node cluster on AWS using Ansible…

  • First of all, you have to launch 3 ec2 instances one for master and the remaining for slaves/workers (by default 2 but we can scale). For this, we require AWS secret key, access key, and public .pem file. You can store your credentials in an ansible vault file.

Playbook for launching ec2 instances…

ec2
ec2
  • Execute this playbook using the below command, You have to wait for some minutes for launching all the instances.
#ansible-playbook ec2.yml --ask-vault-pass

This playbook automatically updates the inventory file for these instances…

inventory

In your workspace, you have the following files,

  • ansible.cfg file
  • k8s_cluster.yml is the main file for configuring Kubernetes multi-node cluster on AWS in one click… it includes,
cluster

Execute this playbook using the following command…

# ansible-playbook k8s_cluster.yml

The playbook has run successfully, now we can check all nodes that all are configured perfectly or not...

Now we can see that our nodes are configured successfully and also they are in a Ready state.

You can find this all set up in my GitHub Repository…

https://github.com/surayyashaikh25/kube-cluster-ansible

Thank you… :)

Keep Learning Keep Sharing !!!

--

--

Surayya Shaikh
Surayya Shaikh

Written by Surayya Shaikh

Technophile | Computer Science Student

No responses yet