Python Microservice Scaffold is an example of how to structure a Flask Microservice Project. This Scaffold is build over PyMS package. PyMS is a Microservice chassis pattern like Spring Boot (Java) or Gizmo (Golang). PyMS is a collection of libraries, best practices and recommended ways to build microservices with Python which handles cross-cutting concerns:
- Externalized configuration
- Logging
- Health checks
- Metrics (TODO)
- Distributed tracing
virtualenv --python=python[3.6|3.7|3.8] venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py runserver
Your default endpoint will be in this url:
http://127.0.0.1:5000/template/
This URL is setted in your config.yml
:
ms:
DEBUG: false
TESTING: false
APP_NAME: Template
APPLICATION_ROOT : /template # <!---
You can acceded to a swagger ui in the next url:
http://127.0.0.1:5000/template/ui/
This PATH is setted in your config.yml
:
pyms:
swagger:
path: "swagger"
file: "swagger.yaml"
url: "/ui/" # <!---
Read more info in the documentation page: https://microservices-scaffold.readthedocs.io/en/latest/
You can dockerize this microservice wit this steps:
-
Create and push the image
docker build -t template -f Dockerfile .
-
Run the image:
docker run -d -p 5000:5000 template
You can run this microservice in a Kubernetes cluster with:
kubectl apply -f service.yaml
See a simple tutorial in the doc
See https://github.com/python-microservices/pyms/blob/master/CONTRIBUTING.md
sphinx-build -b html docs/ _build