This Ansible Project is used to configure the Multinode Kubernetes cluster on AWS on the AMI Amazon Linux 2 with Container Engine Docker and CNI Flannel using the Ansible playbook and roles.
It first Launches an instance on AWS Master node and Worker node according to our choice. Then it contacted this contact to the Instances and configures the Master node after that Worker Nodes.
This how you may start using this Project.
- Install Python 3 on your System.
- Install Ansible using pip.
pip3 install ansible
- Install boto3 and boto python Library using pip.
pip3 install boto3
- Install and Configure AWS CLI 2 (also create a profile).
- Create a AWS private key by the name of awskey or with any other name.
- Clone the Repository
git clone https://github.com/AyushRawat-17/Ansible_K8S_Configuration.git
- Copy the Private key to the root Directory of the project.
- Update the value of private_key_file variable in the ansible.cfg (If you use private key other than awskey.pem)
- Make the ./inventory/ec.py file executable. Use the following command
chmod +x ./inventory/ec.py
- Change the permission of the private key to read only. Use the following command
chmod +400 awskey.pem
- If you are using the private key with some other name change the value of variable key in the this file ./roles/ayushrawat_17.k8s_aws_ec2/vars/main.yml
-
For Role ayushrawat_17.k8s_aws_ec2
- In the root directory of the project execute
cd ./roles/ayushrawat_17.k8s_aws_ec2/vars
- Then open the main.yml using a text editor like vim
eg->vim main.yml
- Variable to be updated are
- no_of_slave - To upate the number to slave node you required
- aws_cli_profile - Update it to your AWS CLI profile Rest of variables remain same
- In the root directory of the project execute
-
For role ayushrawat_17.k8s_aws_master
In this role there is no variable update is required -
For role ayushrawat_17.k8s_aws_slave
- In the root directory of the project execute
cd ./roles/ayushrawat_17.k8s_aws_slave/vars
- Then open the main.yml using a text editor like vim
eg->vim main.yml
- Variable to be updated are
if you are using this role without the ayushrawat_17.k8s_aws_master role upadate the following variable else not required
- hostvar_token_present - Change it to no
- kube_join_token - Put the Token in this variable
- ca_cert_hash- Put the CA certificate hash
- master_ip - Put the master node IP Address
- master_portno - Put the master Port Number
- Go back to Root directory of Project
- Then Execute the following Command
ansible-playbook -v role.yml
- In the root directory of the project execute
Ayush Rawat - @rawatayush17 - ayushrawatkv@gmail.com
Project Link: https://github.com/AyushRawat-17/Ansible_K8S_Configuration