- VPC with 3 private and public subnets.
- 1 NAT Gateway.
- Security Groups for the load balancer and Kubernetes (K8s) nodes.
- Key pair for the nodes.
- Network Load Balancer (NLB) and target group for the master nodes.
- Ansible hosts for master and worker nodes.
To SSH into a private instance through a public jumpbox (bastion):
ssh -i private-key.pem -o ProxyCommand="ssh -i private-key.pem -W %h:%p ubuntu@<bastion_public_ip>" ubuntu@<private_ip>
- Add a new EC2 instance for the master node.
- Update the
null_resource.update_hosts
to include the new master. - Add the new master to the
aws_lb_target_group_attachment
. - Include the new master node in
ansible.tf
under the Ansible hosts. - Add an output for the private IP of the new master.
Once the above changes are made, run:
terraform apply
This will automatically add the new master node to the cluster.
Before removing a master node resource, you must drain and delete the node from the Kubernetes cluster. Execute the following commands:
kubectl drain master3 --ignore-daemonsets
kubectl delete node master3