We want to build a simple API interface prototype
API_KEY
: The API key is hardcoded at the moment, you can generate your own API key. The product API shall parse this key upon request from the headerX-API-KEY
and reject the rest without the headerFLASK_PORT
: Default 5000, this is the port which the flask application will be bound to
- Fork this repository
- Create branch from a previous commit id of master:
git checkout -b dev 9a09dc2f77e2551bb764c86f9269543442007606
- Add the following piece of code on dev and merge the branch to main via pull request, for the sake of health-checking:
@app.route("/health")
def health_check():
return "", 200
- Briefly read through the source code and build the docker image. Push this to your docker repository. If you may, please leave us a simple script in
hack/
for testing the docker image locally - Gain access to the Kubernetes cluster. Deploy your images from docker repository. (Please leave your deployment files in
config/
) - After ensuring the functionality of your application on Kubernetes, please add the healthcheck functionality using the
/health
endpoint you have added, to ensure the application is alive - To increase scalability of the application, please avoid hard-coding your
API_KEY
andFLASK_PORT
. Store these into secrets and configmaps respectively - Deploy gitops tools, e.g.,
fluxcd
orargocd
to the cluster, so that whenever you have pushed a new image to docker repository, the latest version of image will be deployed automatically - build a docker CI pipeline to build and upload the docker image when there is a git push or merge. You can use any service as you like
In your submission we would like to have your repository structurized like this:
.
|
| --- src/
| --- config/
| --- hack/
| --- Dockerfile
| --- requirements.txt
| --- README.md
src/
: Containing scripts
config/
: The configuration files, possibly including your Dockerfile, kubernetes, CI/CD configuration files
hack/
: (optional) some random quick-hack one-liners you find useful and convenient to use