Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eljandoubi/server-deployment-and-containerization
In this project I will containerize and deploy a Flask API to a Kubernetes cluster using Docker, AWS EKS, CodePipeline, and CodeBuild.
https://github.com/eljandoubi/server-deployment-and-containerization
aws-cloudformation aws-codebuild aws-codepipeline aws-eks docker eksctl flask-api kubectl kubernetes python
Last synced: 27 days ago
JSON representation
In this project I will containerize and deploy a Flask API to a Kubernetes cluster using Docker, AWS EKS, CodePipeline, and CodeBuild.
- Host: GitHub
- URL: https://github.com/eljandoubi/server-deployment-and-containerization
- Owner: eljandoubi
- Created: 2024-02-22T18:13:50.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-23T07:09:02.000Z (10 months ago)
- Last Synced: 2024-04-17T15:09:15.792Z (8 months ago)
- Topics: aws-cloudformation, aws-codebuild, aws-codepipeline, aws-eks, docker, eksctl, flask-api, kubectl, kubernetes, python
- Language: Python
- Homepage:
- Size: 3.79 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Deploying a Flask API
In this project I will containerize and deploy a Flask API to a Kubernetes cluster using Docker, AWS EKS, CodePipeline, and CodeBuild.
The Flask app that will be used for this project consists of a simple API with three endpoints:
- `GET '/'`: This is a simple health check, which returns the response 'Healthy'.
- `POST '/auth'`: This takes a email and password as json arguments and returns a JWT based on a custom secret.
- `GET '/contents'`: This requires a valid JWT, and returns the un-encrpyted contents of that token.The app relies on a secret set as the environment variable `JWT_SECRET` to produce a JWT. The built-in Flask server is adequate for local development, but not production, so you will be using the production-ready [Gunicorn](https://gunicorn.org/) server when deploying the app.
## Prerequisites
* Docker Desktop - Installation instructions for all OSes can be found here.
* Git: Download and install Git for your system.
* Code editor: You can download and install VS code here.
* AWS Account
* Python version between 3.7 and 3.9. Check the current version using:
```bash
# Mac/Linux/Windows
python --version
```
You can download a specific release version from here.* Python package manager - PIP 19.x or higher. PIP is already installed in Python 3 >=3.4 downloaded from python.org . However, you can upgrade to a specific version, say 20.2.3, using the command:
```bash
# Mac/Linux/Windows Check the current version
pip --version
# Mac/Linux
pip install --upgrade pip==20.2.3
# Windows
python -m pip install --upgrade pip==20.2.3
```
* Terminal
* Mac/Linux users can use the default terminal.
* Windows users can use either the GitBash terminal or WSL.
* Command line utilities:
* AWS CLI installed and configured using the `aws configure` command. Another important configuration is the region. Do not use the us-east-1 because the cluster creation may fails mostly in us-east-1. Let's change the default region to:
```bash
aws configure set region us-east-2
```
Ensure to create all your resources in a single region.
* EKSCTL installed in your system. Follow the instructions [available here](https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html#installing-eksctl) or here to download and install `eksctl` utility.
* The KUBECTL installed in your system. Installation instructions for kubectl can be found here.## Initial setup
1. Fork the Server and Deployment Containerization Github repo to your Github account.
1. Locally clone your forked version to begin working on the project.
```bash
git clone https://github.com/eljandoubi/Server-Deployment-and-Containerization.git
cd cd0157-Server-Deployment-and-Containerization/
```
1. These are the files relevant for the current project:
```bash
.
├── Dockerfile
├── README.md
├── aws-auth-patch.yml
├── buildspec.yml
├── ci-cd-codepipeline.cfn.yml
├── iam-role-policy.json
├── main.py
├── requirements.txt
├── simple_jwt_api.yml
├── test_main.py
└── trust.json
```