The repository for creating Kubernetes Cluster using Ansible Roles.
The folder named K8s_Cluster_Roles has three roles named EC2_instance , K8_Master , K8_Slave . The role launches two instances over aws cloud , configures one instance as Master , other instance as Slave respectively.
The folder named /mydb is used to setup the dynamic inventory which will automatically load the IPs of the instances. It contains two files namely ec2.py and ec2.ini. Follow the changes made in the file and make them executable using
chmod +x filename
Export all the variables mentioned in the ec2.py file. ..
Check the dynamic inventory setup by runnig ec2.py file. Run the following command in the same directory
./ec2.py
Ansible configuration file is located in /etc/ansible/ansible.cfg as a default location. We add the following parameters to execute the playbook remotely - connection , remote user , path of key to your AWS account. Since the instances launch will not have power to executethe tasks add privilege escalation to your config file. Since, we going to run roles add the role path and certain other details as well.
The main setup file contains three hosts with their respective roles . The role which launches instance is run locally. The other two are run respectively on the name assigned to them while launching tag_Name_nameofinstance . In the end run this file to configure the entire structure using the command:
ansible-playbook filename
You can go through the article more details .