Create AWS Infrastructure
This page provides steps to prepare AWS infrastructure for kubernetes deployment.
warning
These are my personal notes and not an official guide for creating AWS resources using Pulumi. Following these instructions may incur AWS costs.
Create Pulumi Project
We will begin by creating an empty AWS Pulumi Python project. Refer to the steps provided here to set up a Pulumi project. Once the Pulumi project is ready, set up the Python project structure and configure tox for unit testing using the steps outlined here.
Provision VPC & EC2
Refer to steps here
We will install Kubernetes using Kubeadm. Below are the prerequisites for Kubeadm.
- A compatible Linux host. Linux distribution based on Debian and Red Hat.
- GB or more RAM per machine.
- CPU or more per machine.
- Full network connectivity between all machines in the clusters.
- Unique hostname, MAC address, and product_uuid for every node.
- Certain ports open on your machine.
- Swap disabled for kublets to work properly.
Write a code in Pulumi to create below resources:
- Create AWS Organization.
- Create a Security Group and configuring it for required ports. To get the lists of required port click here.
- Create VPC with both public and private subnets.
- Setup CIDR block and allocate elastic IP using NAT gateway.
- EC2 Instances.
- Create EC2 instance and assign them to private and public subnets.
- Add Storage
Prepare EC2 Instances
See if you can use pulumi for below tasks or use Ansible:
- Update and upgrade apt.
- Disable swap.
- Rename hostname.
- Install container runtime: Docker.
sudo apt-get install docker.io --yes
- Add user to docker group, if user is not able to run the docker commands
sudo usermod --groups docker --append <username>
- Install kubeadm, kubelet and kubectl. Click here for the steps.
- Reboot.