Given application implements simple REST API written in Python with a help of the Flask framework.
-
Description: Saves/updates the given user's name and date of birth in the database Request: PUT /hello/<username> { "dateOfBirth": "YYYY-MM-DD" }
Response: 204 No Content
Notes:
<username>
must contain only lettersYYYY-MM-DD
must be a date before the today date
-
Description: Returns hello birthday message for the given user Request: GET /hello/<username>
Response: 200 OK
Response Examples:
-
If username's birthday is in N days:
{ "message": "Hello, <username>! Your birthday is in N day(s)" }
-
If username's birthday is today:
{ "message": "Hello, <username>! Happy birthday!" }
-
-
Descrition: Returns current application based on DB availability Request: GET /status
Response: 200 OK
Response Examples:
-
Successful response:
{ "status": "OK" }
-
Failed response:
{ "status": "DB connection error", "error": "Can't connect to MySQL database" }
-
Development lifecycle implies Git Feature Branch Workflow.
On commit to the repository GitHub Action wokflow will be triggered and will
execute basic code checks and python unit tests with a help of pre-commit
On merge to the main
branch GitHub Action wokflow, apart from pre-commit
checks,
will build and publish Container image and Helm chart artifacts to GitHub Container registry and Packages respectively.
To build image locally:
task docker-build
You can instantiate docker image without docker-compose
. In such case, if no extra arguments passed, application will
use sqlite
for storage backend. To do so, execute:
task docker-run
Docker Compose can be used to bring up a simple DEV
environment comprised of application and mysql database.
Before the first execution, create a .env
file in the /app
folder with the default configuration. You can do it by
copying the .env.example
file or by running
task compose-setup
Bring environment up:
task compose-up
Bring environment down:
task compose-down
Minikube mimics a production-like setup. It is configured to provision ArgoCD for application delivery, Bitnami MySQL
Helm chart as a storage layer and the application itself. App Helm chart configuration enables a RollingUpdate
deployment strategy that allows for zero-downtime deployment.
Bring environment up:
task minikube-up
Bring environment down:
task minikube-down
This repo uses Task to help with daily routine tasks. Run task -l
to see available options:
$ task -l
task: Available tasks for this project:
* compose-down: docker-compose down
* compose-logs: docker-compose logs
* compose-setup: Setup Docker Compose environment
* compose-up: docker-compose up
* docker-build: Build Docker Image
* docker-run: Run Docker container
* minikube-down: Delete minikube cluster
* minikube-up: Bootstrap minikube cluster
* precommit: Execute pre-commit for modified files
* precommit-all: Execute pre-commit for all files
* setup: Setup pre-commit
* unittest: Run application unit tests
To ensure consistency and code quality across the repository we use:
For local development you will need following tools:
Dependency tracking and management handled by Renovate. It is configured with following backends:
- docker-compose
- dockerfile
- github-actions
- helm-values
- helm-charts
- kubernetes
- pip-requirements
- pre-commit
- Check version bump in
/app/VERSION
- Improve documentation