Giter Club home page Giter Club logo

mini-api's Introduction

Mini API

Scenario

We want to build a simple API interface prototype

Necessary Environment Variables

  • 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 header X-API-KEY and reject the rest without the header
  • FLASK_PORT: Default 5000, this is the port which the flask application will be bound to

Steps

  1. Fork this repository
  2. Create branch from a previous commit id of master: git checkout -b dev 9a09dc2f77e2551bb764c86f9269543442007606
  3. 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
  1. 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
  2. Gain access to the Kubernetes cluster. Deploy your images from docker repository. (Please leave your deployment files in config/)
  3. After ensuring the functionality of your application on Kubernetes, please add the healthcheck functionallity using the /health endpoint you have added, to ensure the application is alive
  4. To increase scalability of the application, please avoid hard-coding your API_KEY and FLASK_PORT. Store these into secrets and configmaps respectively
  5. Deploy gitops tools, e.g., fluxcd or argocd to the cluster, so that whenever you have pushed a new image to docker repository, the latest version of image will be deployed automatically
  6. 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

Outcome:

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

mini-api's People

Contributors

jayay98 avatar alphawong avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.