This repo is a demo of how one could deploy a highly available, scalable REST api in modern cloud infrastructure.
- DevOps Technical Exercise
- Table of contents
- System Requirements
- Setup
- How to build
- How to deploy
- Clean up
- Docker (Tested on
Docker version 20.10.21, build baeda1f
) - Python3 (Tested on
Python 3.9.13
) - Kubernetes (Tested on windows platform Client v1.26, linux platform Server v1.25, Kustomize v4.5.7)
- aws cli (version: aws-cli/2.9.17)
- Configure the aws cli
- Terraform (tested on version 1.3.7)
- Install Python3
- Install Docker
- Install Terraform
- Install Kubernetes
- Install aws cli
- Configure the aws cli
- create a venv
python3 -m venv myenv
- activate venv
./myenv/scripts/activate
- run
pip install -r ./requirements.txt
- run
terraform init
$ fab tag:v1.0.1 build_image
This command will build a docker image of the dotnet app located in the ./App
directory and tag the image with v1.0.1
. The build is a multi-stage build done to reduce the final image size to just the bare bones. In the first phase of the build unit tests are ran ensuring a new image will get built only when unit tests pass. The second phase of the build copies the published build into a lightweight container and sets the container entry point to the REST api.
If you have a private repo
$ fab hub:<repository> tag:v1.0.2 publish
Additionally you can set REST_DOCKER_REPOSITORY
and exclude the hub
target.
This command builds an image and pushes to a remote repository.
fab tag:v1.0.1 apply
This command first creates a VPC with 3 private class C subnets and 3 public subnets, security groups, Elastic Network Interfaces, Elastic Load Balancer, and an EKS cluster with two managed node groups of t3.small ec2 instances. Next it deploys a kubernetes Deployment and Service to the provisioned EKS cluster. It exposes port 80 to the outside world and configures the Service as a LoadBalancer enabling traffic distribution, auto-scaling, rolling updates and more out of the box.
fab destroy
Removes all AWS resourcesdocker rmi jburns24/rest-api:<version>
Removes the docker image