Pymacaron

Star
Logo

A python microservice framework

Reference:

Overview
Quick start
Project files
OpenAPI specification
API objects
Server code
Deployment pipeline
Docker packaging
JWT authentication
Configuration
Error handling
Asynchronous execution
Database serialisation
Testing
Monitoring

Deployment Pipeline

PyMacaron microservices are designed to support multiple deployment targets. Currently, both AWS Beanstalk and Google Cloud Run are supported.

Deployment pipeline with pymdeploy

bin/pymdeploy implements the deployment pipeline of PyMacaron microservices, which consists of the following steps:

  1. Execute unittests under ‘test/’ with nosetests. Stop if tests fail.

  2. Generate a docker image in which the app starts inside gunicorn.

  3. Start this image in a local docker instance and run acceptance tests from the ‘testaccept/’ directory against it. Stop if tests fail.

  4. Push that image to a container registry, either docker.io or gcr.io.

  5. Deploy the image to a cloud environment: either by creating a new Beanstalk environment on AWS, or by doint a rolling deploy to a staging environment in GKE or Google Cloud Run.

  6. Run acceptance tests against the cloud environment. Stop if they fail.

  7. Deploy the image to a live cloud environment: either by doing a blue/green deployment of the newly created Beanstalk environment on AWS, or by re-deploying the image to a live environment on GKE or Google Cloud Run.

  8. Run acceptance tests again, this time against the live environment, as a final validation.

Usage

To execute the full deployment pipeline, do:

cd your-project-root
pymdeploy

For more usage examples, see ‘pymdeploy –help’.

Targeted clouds

AWS Beanstalk

See instructions here.

Google Kubernetes Engine (GKE)

See instructions here.

Google Cloud Run

See instructions here.

Identifying runtime inside the app

How can a pymacaron service know if it is being executed inside a container started by ‘pymtest’, or in a staging respectively live deployment on google cloud or aws? By looking at the ‘PYM_ENV’ environment variable, documented here.