Contents
-
Networking Setup
- VPC
- Public and Private Subnets
- InternetGateway
- NAT Gateway
- Route Tables
-
Compute Setup
- Security Groups
- EC2 Controller Node
-
EKS
- EKS Cluster
- Installed packages
- Python
- AWS-CLI v2
- Jenkins
- kubectl
- Docker
Prerequisites
AWS free tier
accountaws-cli
must be configured on your system for executing cloudformation scripts- Familiar with
bash
scripts
Steps
- Login to you AWS Console and go to EC2 section in us-east-1 region
- Go to KeyPair section and create a new KeyPair with the name udacity-project and then you'll have udacity-project.pem file on your local at destination ~/Downloads/udacity-project.pem. Make sure it is on this path only.
- Run
aws configure
and add your access key and secret key and use region us-east-1
- Now run
bash create-infra.sh
. Now head to cloudFormation service in AWS Console and you will see a new stack with name udacity-capstone is creating. - After the stack has been created, in the output section, you will get the Public IP of the controller instance.
- Replace this IP in roles/inventory.ini as
ubuntu@<public-ip>
- This will turn up the following components
- VPC
- Public and Private Subnet in 2 different AZs
- Internet Gateway
- Nat Gateway
- RouteTable
- ControllerNode
- EKS Cluster
- On AWS Console, Go to EKS section and create NodeGroup. Attach the required IAM Role to the NodeGroup and test them using the command
kubetl get nodes
- Now run
bash setup-controller.sh <public-ip>
. This will configure the controller node by executing ansible role over the controller node and will return the Jenkins IP and its InitialAdminPassword - Open Jenkins and configure it. After configuring, you need to add plugins related to BlueOcean, Docker and Pipeline: AWS Steps.
- After adding the plugins, go to credentials section and add Docker Credentials with the name dockerhub-credentials.
- Now head to BlueOcean and create your first project pipeline by configuring this repository.
- Run the pipeline and you will see that the pipeline will perform the following
- Check Linting of the HTML
- Build the docker image from the dockerfile
- Push the docker image to Dockerhub
- Deploy the image on EKS using deployment-rolling-update.yaml
- Test Rolling update by changing the HTML file with some new content and trigger the jenkins build again.
- You will see that the pods will go down 1 by 1 and new pods will start replacing them.