The goal for this repository is to show the knowledge acquired during the execution of the SRE Bootcamp in particular with this major areas
- Demonstrate the CI/CD, testing and clean code knowledge you acquired from the Bootcamp first modules.
- Demonstrate the adaptability to learning new technologies.
- Demonstrate the knowledge of infrastructure and code you acquired from the Bootcamp last modules.
Metric | development | staging | main (Production) |
---|---|---|---|
CI/CD |
Endpoint | Description |
---|---|
/ | Homepage |
/version | Reports the Container SHA |
/_health | Application health |
/login | Returns a JSON Web Token (JWT) |
/cidr-to-mask | Converts from CIDR notation to Sub-Network Mask |
/mask-to-cidr | Converts form Sub-Network Mask notation to CIDR |
- Software Engineering and Testing Best Practices
- SDLC implemented via TDD
- Computing AWS
- EC2
- ECS
- AWS Data Storage
- S3
- DynamoDB
- RDS (mysql)
- Cloud Security Best Practices
- Single entry to the application via ELB
- Bastion Hosts to reach the VPC
- Application and DB allocated in private networks.
- NACs on Public Network
- Security Groups in All network
- Roles and Policies
- DevOps & CI/CD Fundamentals
- Docker + DockerCompose Workflow
- 2 Services enabled
- Flask Application
- DataStore (mysql) with Test Data
- 2 Services enabled
- Single CI/CD pipeline with 4 gates
- Static Code Verification (pylint)
- Unit Test (pytest)
- Code Coverage up to 100%
- Docker + DockerCompose Workflow
- Infrastructure as Code (IaC)
- State file stored via S3
- Lock system implemented via DynamoDB
- Three environments defined
- Development
- Staging
- Production
docker pull manquintero/academy-sre-bootcamp-manuel-quintero
docker run -d -p 8000:8000 manquintero/academy-sre-bootcamp-manuel-quintero
docker pull 664624836310.dkr.ecr.us-east-2.amazonaws.com/academy-sre-bootcamp-manuel-quintero
docker run -d -p 8000:8000 664624836310.dkr.ecr.us-east-2.amazonaws.com/academy-sre-bootcamp-manuel-quintero
docker pull gcr.io/academy-sre-bootcamp/academy-sre-bootcamp-manuel-quintero
docker run -d -p 8000:8000 gcr.io/academy-sre-bootcamp/academy-sre-bootcamp-manuel-quintero
In order to bring the development area execute:
docker-compose up --build
This will bring the application container along with its database with sample data
pip install pylint
[[ -f "./python/requirements.txt" ]] && pip install -r "./python/requirements.txt"
pylint python/
pip install pytest pytest-cov mock
[[ -f "./python/requirements.txt" ]] && pip install -r "./python/requirements.txt"
pytest python
pytest --cov-config=python/.coveragerc --cov python > pytest-coverage.txt
Although described as UT these runs rely on an external DB provided by the original project
$ curl -s localhost:8000
OK
$ curl -s localhost:8000/_health
HEALTHY
$ curl -s localhost:8000/version
HEAD
$ curl -s -d "username=antonio&password=cotorro" http://127.0.0.1:8000/login
{"data":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoidmlld2VyIn0._k6kmfmdOoKWWMT4qk9nFTz-7k-X_0UdS8tByaCaye8"}
$ TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoidmlld2VyIn0._k6kmfmdOoKWWMT4qk9nFTz-7k-X_0UdS8tByaCaye8"
$ curl -s -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" localhost:8000/cidr-to-mask?value=18
{"function":"cidrToMask","input":"18","output":"255.255.192.0"}
$ TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoidmlld2VyIn0._k6kmfmdOoKWWMT4qk9nFTz-7k-X_0UdS8tByaCaye8"
$ curl -s -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" localhost:8000/mask-to-cidr?value=255.128.0.0
{"function":"maskToCidr","input":"255.128.0.0","output":"9"}
A simple branch strategy based on the mythical GitGlow with a few tailoring to fit this application lifecycle. These are the key points:
- The branches mimic the target environments:
- Any number of commits to the development branch can happen.
- Changes from development shall be promoted to a staging via GitHub pull requests merge.
- Any number of commits to the staging branch can happen.
- Only pull request merges are allowed on Production
- So far, no hot fixes are allowed in Production
The CI/CD process has been merged into a single pipeline for convenience. A few adaptations depends on the type of trigger.
- Build
- Checks for SCCD in Python. [merge && pull_request]
- Test
- Checks for Unit Testing via pytest. [merge && pull_request]
- Checks for Code Coverage. [merge && pull_request]
- Container
- Builds the containers. [merge && pull_request]
- Tags and Pushes to three different Cloud Registries. [merge]
- Terraform
- Initialize the workspace. [merge && pull_request]
- Checks for formatting. [merge && pull_request]
- Plan the provisioning. [merge]
- Apply the provisioning plan. [merge]
Systems with a lock mechanism in place, such as Terraform, are protected via GitHub environment concurrency
Three Environments have been designated based on the Branching Strategy:
The strategy is layered in two stages:
- EC2 with an AutoScaling Group following a rolling-update process where wait_for_elb_capacity is defined.
- ECS with a deployment_circuit_breaker configured with rollback.
- Every Service/Task feeds from the same ECR but different task definition with the SHA embedded into it.
Modules were defined for the next functionalities: