Create the Python Microservice with `pyms`

Python Microservices — PyMS

PyMS, Python MicroService, 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
  • Distributed tracing

PyMS is powered by Flask, Connexion and Opentracing.

Activate the Virtual Environment

These steps are according to my skill level in python for creating a virtual environment

Environment activation is not mandatory to create the microservice with `pyms`

Install pyms

Create a project from scaffold

PyMS has a command-line option to create a project template like Microservices Scaffold.

Prerequisite

- `PyMS` uses cookiecutter to download and install this template

- Create a git repository and keep the repo URL copied [Optional]

Create the Project

Interactive way of answering a few questions to create the project.

Run Application

Do some code changes in the manage.py which in bold or check with the tutorials in Tutorial Example.

run the application with

Output:

Run the application as a container

Create the docker images with

Run the container with

Now the application is up and running on `http://127.0.0.1:5001/`

Reference

1. [PyMS](https://py-ms.readthedocs.io/en/latest/)

2. [Python Microservices Github](https://github.com/python-microservices/microservices-scaffold)

Devops Manager, Practising Natural Farming