This is the project starter repo for the fourth course in the Udacity Full Stack Nanodegree: Server Deployment, Containerization, and Testing.
In this project you 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 server when deploying the app.
- Fork this project to your Github account.
- Locally clone your forked version to begin working on the project.
- Docker Engine
- AWS Account
- You can create an AWS account by signing up here.
Create a file named .env_file
and save both JWT_SECRET
and LOG_LEVEL
into .env_file
.
These environment variables will run locally in your container.
Here, we do not need the export command, just an equals sign:
JWT_SECRET='myjwtsecret'
LOG_LEVEL=DEBUG
This .env_file
is only for the purposes of running the container locally, you do not want to push it into the Github or other public repositories.
You can prevent this by adding it to your .gitignore
file, which will cause git to ignore it.
To safely store and use secrets in the cloud, use a secure solution such as AWS’s parameter store.
Completing the project involves several steps:
- Write a Dockerfile for a simple Flask API
- Build and test the container locally
- Create an EKS cluster
- Store a secret using AWS Parameter Store
- Create a CodePipeline pipeline triggered by GitHub checkins
- Create a CodeBuild stage which will build, test, and deploy your code
For more detail about each of these steps, see the project lesson here.
If no production you can stop your machine as below:
Go to EC2 instances dashboard of your Node Group and from right panel in bottom click on Auto Scaling Groups then select your group by click on checkbox and click edit button and change Desired, Min & Max capacities to 0 (before all are 2).