From b801bab999cb121fa78a1f91ca1e3189c03a2a21 Mon Sep 17 00:00:00 2001 From: Yazmin Cumberbirch Date: Sun, 12 Apr 2020 21:24:55 +0200 Subject: [PATCH 01/13] Check english in docs --- docs/command_line.md | 10 +++---- docs/configuration.md | 42 ++++++++++++++-------------- docs/encrypt_decryt_configuration.md | 24 ++++++++-------- docs/examples.md | 8 +++--- docs/index.md | 6 ++-- docs/ms_class.md | 10 +++---- docs/quickstart.md | 18 ++++++------ docs/routing.md | 4 +-- docs/services.md | 28 +++++++++---------- docs/structure.md | 4 +-- docs/tutorial_propagate_traces.md | 18 ++++++------ 11 files changed, 86 insertions(+), 86 deletions(-) diff --git a/docs/command_line.md b/docs/command_line.md index 933099f..e97fc34 100644 --- a/docs/command_line.md +++ b/docs/command_line.md @@ -1,11 +1,11 @@ # Commnand line -PyMS has some command to make easy your developments: +PyMS hcomes with some commands to make your developments easier: ```bash pyms -h ``` -Show you a list of options and help instructions to use this command like: +Lists the options and help instructions to use this command: ```bash usage: main.py [-h] [-v VERBOSE] {encrypt,create-key,startproject} ... @@ -35,11 +35,11 @@ Command: pyms startproject ``` -This command create a project template like [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold). -This command use [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) +This command creates a project template like the one defined in [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold). +This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) !!! warning - You must run first `pip install cookiecutter==1.7.0` + First, you must run `pip install cookiecutter==1.7.0` ## Create a key encrypt/decrypt file diff --git a/docs/configuration.md b/docs/configuration.md index 5d67e80..ca21ba8 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,20 +2,20 @@ ## Environments variables of PyMS: -**CONFIGMAP_FILE**: The path to the configuration file. By default, PyMS search the configuration file in your -actual folder with the name "config.yml" -**KEY_FILE**: The path to the key file to decrypt your configuration. By default, PyMS search the configuration file in your -actual folder with the name "key.key" +**CONFIGMAP_FILE**: The path to the configuration file. By default, PyMS searches for the configuration file in your +current folder with the name "config.yml" +**KEY_FILE**: The path to the key file to decrypt your configuration. By default, PyMS searches for the configuration file in your +current folder with the name "key.key" ## Create configuration -Each microservice needs a config file in yaml or json format to work with it. This configuration contains -the Flask settings of your project and the [Services](services.md). With this way to create configuration files, we +Each microservice needs a config file in yaml or json format for it to work with. This configuration contains +the Flask settings of your project and the [Services](services.md). With this way of creating configuration files, we solve two problems of the [12 Factor apps](https://12factor.net/): - Store config out of the code -- Dev/prod parity: the configuration could be injected and not depends of our code, for example, Kubernetes configmaps +- Dev/prod parity: the configuration could be injected and doesn't depend on our code, for example, Kubernetes configmaps -a simple configuration file could be a config.yaml: +A simple configuration file could be a config.yaml: ```yaml pyms: @@ -60,18 +60,18 @@ or in a config.json: } ``` -This file could contains this keywords: +This file can contain the following keywords: ## pyms - services block ```pyms```: all subsets inside this keyword are the settings of this library. Each keyword will be a service of our -[Microservice class](ms_class.md). For example, we declare our microservice class as: +[Microservice class](ms_class.md). For example, if we declare our microservice class as: ```python from pyms.flask.app import Microservice ms = Microservice(path=__file__) ``` -and a `config.yaml` file: +and have a `config.yaml` file such as: ```yaml pyms: @@ -79,13 +79,13 @@ pyms: requests: true ``` -our object `ms` has an attribute `requests` that is a instance of our service [requests](services.md). +our `ms` object will have an attribute `requests` that is a instance of our service [requests](services.md). ## pyms - config block -This part contains all keywords of a [Flask Configuration Handling](http://flask.pocoo.org/docs/1.0/config/) and our -constants of the enviroments (local configuration, staging configuration...). Keep in mind that a Flask configuration needs -the keywords to be declared as uppercase. If you defined a variable like `app_name`, you will get this with -`current_app.config["APP_NAME"]` +This section contains all keywords used for general [Flask Configuration Handling](http://flask.pocoo.org/docs/1.0/config/), along +with our constants for the different the enviroments (local configuration, staging configuration...). Keep in mind that +a Flask app configuration needs the keywords to be declared as uppercase. If you defined a variable like `app_name`, +you will be able to retrieve it this with `current_app.config["APP_NAME"]` ## Import Configuration @@ -98,7 +98,7 @@ def my_endpoint(): print(current_app.config["DEBUG"]) ``` -But, what happend if you need the configuration BEFORE Flask class is instanced? Imagine this case: +But, what happens if you need to access the configuration BEFORE Flask class is instanced? Imagine this case: ```python from flask import Blueprint, current_app @@ -115,7 +115,7 @@ API = Api( ) ``` -This raise a `'working outside of application context` error. Who can solve this problem? +This raises a `'working outside of application context` error. Who can solve this problem? ```python from flask import Blueprint, current_app @@ -135,10 +135,10 @@ API = Api( ## Looking for Configuration file with Kubernetes Configmaps -By default, Microservice class search a config.yml in the same path. You can set a different route or set a json file. -To change this path, define a environment variable `CONFIGMAP_FILE`. +By default, a Microservice class searches for a config.yml in the same path. You can set a different route or set a json file. +To change this path, you must define a environment variable `CONFIGMAP_FILE`. -This way of looking for the configuration is useful when you work with Docker and Kubernetes. For example, you can integrate +This way of looking for the configuration is useful when you work with Docker and Kubernetes. For example, you could integrate a configmap of Kubernetes, with this microservice and a deployment with: ```yaml diff --git a/docs/encrypt_decryt_configuration.md b/docs/encrypt_decryt_configuration.md index a7dac00..66f11f3 100644 --- a/docs/encrypt_decryt_configuration.md +++ b/docs/encrypt_decryt_configuration.md @@ -3,7 +3,7 @@ ## Configuration When you work in multiple environments: local, dev, testing, production... you must set critical configuration in your -variables, like: +variables, such as: config.yml, for local propose: ```yaml @@ -29,8 +29,8 @@ pyms: You can move this file to a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), use [Vault](https://learn.hashicorp.com/vault) or encrypt the configuration with [AWS KMS](https://aws.amazon.com/en/kms/) - or [Google KMS](https://cloud.google.com/kms). We strongly recommended this ways to encrypt/decrypt your configuration, - but if you want a no vendor locking option or you haven`t the resources to use this methods, we create a way to encrypt + or [Google KMS](https://cloud.google.com/kms). We strongly recommend these of encrypting/decrypting your configuration, + but if you want a no vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt and decrypt your variables. ## 1. Generate a key @@ -44,20 +44,20 @@ pyms create-key Then, type a password and it will create a file called `key.key`. This file contains a unique key. If you loose this file and re-run the create command, the key hash will be different and your code encrypted with this key won't be able to be decrypted. -Store the key in a secure site, and NOT COMMIT this key to your repository. +Store this key in a secure site, and DO NOT COMMIT it to your repository. ## 2. Add your key to your environment -Move, for example, your key to `mv key.key /home/my_user/keys/myproject.key` +Move your key, for example, to `mv key.key /home/my_user/keys/myproject.key` -then, store this key in a environment variable with: +then, store the in a environment variable with: ```bash export KEY_FILE=/home/my_user/keys/myproject.key ``` -## 3. Encrypt your information and put in config +## 3. Encrypt your information and store it in config Do you remember the example file `config_pro.yml`? Now you can encrypt and decrypt the information, you can run the command `pyms encrypt [string]` to generate a crypt string, for example: @@ -67,7 +67,7 @@ pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' >> Encrypted OK: b'gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA==' ``` -And put this string in your `config_pro.yml`: +And store this string in your `config_pro.yml`: ```yaml pyms: config: @@ -83,9 +83,9 @@ can find the answer ## 4. Decrypt from your config file -Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS searchs for your key file -in the `KEY_FILE` env variable and decrypt this value and store it in the same variable without the `enc_` prefix, -por example, +Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS searches for your key file +in the `KEY_FILE` env variable and decrypts this value to store it in the same variable without the `enc_` prefix, +for example, ```yaml ENC_SQLALCHEMY_DATABASE_URI: gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA== @@ -97,4 +97,4 @@ Will be stored as SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/my_schema ``` -And you can access to this var with `current_app.config["SQLALCHEMY_DATABASE_URI"]` +And you can access this var with `current_app.config["SQLALCHEMY_DATABASE_URI"]` diff --git a/docs/examples.md b/docs/examples.md index 1684117..5713f11 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -42,7 +42,7 @@ Open in your browser http://localhost:5000/ ## Example 2: Create your Microservice class -Create a class that inherit from `pyms.flask.app.Microservice` and override methods with your own configuration. +Create a class that inherits from `pyms.flask.app.Microservice` and overrides methods with your own configuration. The next example show how to innit a lib like [Flask Babel](https://pythonhosted.org/Flask-Babel/) main.py: @@ -63,7 +63,7 @@ app = ms.create_app() ## Example 2: Initialize SQLAlchemy -The next example show how to innit a lib like [Flask SQLAlchemy](https://flask-sqlalchemy.palletsprojects.com/en/2.x/) +The next example shows us how to innit a lib like [Flask SQLAlchemy](https://flask-sqlalchemy.palletsprojects.com/en/2.x/) config.yml: @@ -99,7 +99,7 @@ app = ms.create_app() ## Example 3: Create your logger -The next example show how to create a personal logger for your application +The next example shows us how to create a personal logger for your application ```python import logging.config @@ -146,4 +146,4 @@ ms = MyMicroservice(path=__file__) app = ms.create_app() ``` -See [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) to see a examples \ No newline at end of file +See [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) to see more examples \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 8afc8cd..d062e7c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ Get started with [Installation](installation.md) and then get an overview with t ## Motivation -When we started to create microservice with no idea, we were looking for tutorials, guides, best practices, but we found +When we started to create a microservice with no previous knowledge, we started looking for tutorials, guides, best practices, but we found nothing to create professional projects. Most articles say: - "Install flask" @@ -25,10 +25,10 @@ nothing to create professional projects. Most articles say: - (Sometimes) "Create a swagger specs" - "TA-DA! you have a microservice" -But... what happens with our configuration out of code like Kubernetes configmap? what happens with transactionality? +But... what happens when we want our configuration out of the code, such as a Kubernetes configmap? what happens with transactionality? If we have many microservices, what happens with traces?. -There are many problems around Python and microservices and we can`t find anyone to give a solution. +There are many problems around Python and microservices and we couldn't find anyone to give us a solution. We start creating these projects to try to solve all the problems we have found in our professional lives about microservices architecture. diff --git a/docs/ms_class.md b/docs/ms_class.md index 7ebb2d3..e36b4da 100644 --- a/docs/ms_class.md +++ b/docs/ms_class.md @@ -1,6 +1,6 @@ # Microservices class -The class Microservice is the core of all microservices built with PyMS. +The Microservice class is the core of all microservices built with PyMS. You can create a simple microservice such as: @@ -30,9 +30,9 @@ pyms: config: APP_NAME: "Python Microservice" ``` -Check [Configuration](configuration.md) section to know how to create a configuration file. +Check the [Configuration](configuration.md) section to learn how to create a configuration file. -`Microservice` class search for a `config.yml` in the directory you pass in `path` parameter or search the file in +The `Microservice` class searches for a `config.yml` in the directory you pass in `path` parameter or looks fot the file in `CONFIGMAP_FILE` env var. Each keyword in our configuration block, can be accessed in our Microservice object through the attribute `config`. @@ -67,7 +67,7 @@ print(ms.config.multiplevars.config2) ## Personalize your microservices -Microservice class initialize the libraries and other process by this way: +The Microservice class initializes libraries and other process in the following way: ```python ... @@ -97,4 +97,4 @@ Microservice class initialize the libraries and other process by this way: ``` -Check more examples in [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) \ No newline at end of file +Check for more examples in [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) \ No newline at end of file diff --git a/docs/quickstart.md b/docs/quickstart.md index f69d374..06b0896 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -2,7 +2,7 @@ This page gives a good introduction to PyMS. It assumes you already have PyMS installed. If you do not, head over to the [Installation](installation.md) section. -You need to create 2 files: main.py and config.yml: +To start out, you need to create 2 files: main.py and config.yml: main.py ```python @@ -38,20 +38,20 @@ pyms: ## So what did that code do? -1. Create a instance of PyMS Microservice class (#1.1). This initialization inject the configuration defined in the -1.3 block and could be accessed through current_app.config. Then, initialize the service defined in the 1.2 block. See [Services](services.md) for more details. +1. Create a instance of PyMS Microservice class (#1.1). This initialization injects the configuration defined in the +1.3 block, so it could be accessed through current_app.config. Then, it initializes the service defined in the 1.2 block. See [Services](services.md) for more details. 2. Initialize [Flask](https://flask.palletsprojects.com/en/1.1.x/) instance, [Connexion](https://github.com/zalando/connexion) if it was defined in the pyms configuration block, create a tracer, add health-check blueprint, initialize libs and set the PyMS Microservice in -`ms` attribute and you can access to it with `current_app.ms`. This steps has their each functions and you can easy override it. -3. `create_app` return the flask instance and you can interact with it as a typical flask app +`ms` attribute and you can access to it with `current_app.ms`. These steps all have their own functions and you can easy override any of them. +3. `create_app` returns the flask instance and you can interact with it as a typical flask app # Create a project from scaffold PyMS has a command line option to create a project template like [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold). -This command use [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) +This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) !!! warning - You must run first `pip install cookiecutter==1.7.0` + Fist, you must run `pip install cookiecutter==1.7.0` ## Installation @@ -60,7 +60,7 @@ pyms startproject ` `` -this output a lot of options step by step +this outputs a lot of options step by step ```bash project_repo_url [https://github.com/python-microservices/microservices-scaffold]: @@ -82,6 +82,6 @@ Select open_source_license: Choose from 1, 2, 3, 4, 5, 6 [1]: ``` -When you finish to introduce the options, a project will be created in `[project_folder]` folder +When you finish introducing the options, a project will be created in `[project_folder]` folder See [Configuration](configuration.md), [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial \ No newline at end of file diff --git a/docs/routing.md b/docs/routing.md index 55e4e71..f9e0c4b 100644 --- a/docs/routing.md +++ b/docs/routing.md @@ -19,13 +19,13 @@ Now, you can create a `swagger.yaml` file with [OpenAPI Specification](https://s # Examples of routing -You can see how structure a project or OpenAPI Specification in +You can see how to structure a project or OpenAPI Specification in [PyMS examples](https://github.com/python-microservices/pyms/tree/master/examples/microservice_swagger) or in [Microservice Scaffold](https://github.com/python-microservices/microservices-scaffold) ## Routing to files -This section is equal from [Zalando Connexion](https://github.com/zalando/connexion#automatic-routing), because PyMS use +This section is equal to [Zalando Connexion](https://github.com/zalando/connexion#automatic-routing), because PyMS uses this library to route endpoints to functions: **Explicit Routing**: diff --git a/docs/services.md b/docs/services.md index 9ffc666..338ac88 100644 --- a/docs/services.md +++ b/docs/services.md @@ -1,11 +1,11 @@ # Services Services are libraries, resources and extensions added to the Microservice in the configuration file. -This services are created as an attribute of the [Microservice class](ms_class.md) to use in the code. +These services are created as an attribute of the [Microservice class](ms_class.md) to use in the code. To add a service check the [configuration section](configuration.md). -You can declare a service but activate/deactivate with the keyword `enabled`, like: +You can declare a service but activate/deactivate with the keyword `enabled`, like so: ```yaml pyms: @@ -14,7 +14,7 @@ pyms: enabled: false ``` -Current services are: +Currently availabe services are: ## Swagger / connexion @@ -26,7 +26,7 @@ You must install `pyms` with `pip install pyms[all]` or `pip install pyms[swagge ### Configuration -The parameters you can add to your config are: +The parameters you can add to your config are the folowing: * **path:** The relative or absolute route to your swagger yaml file. The default value is the current directory * **file:** The name of you swagger yaml file. The default value is `swagger.yaml` @@ -50,7 +50,7 @@ pyms: ## Requests Extend the [requests library](http://docs.python-requests.org/en/master/) with trace headers and parsing JSON objects. -Encapsulate common rest operations between business services propagating trace headers if set up. +Encapsulates common rest operations between business services propagating trace headers if set up. ### Installation @@ -61,9 +61,9 @@ You must install `pyms` with `pip install pyms[all]` or `pip install pyms[reques The parameters you can add to your config are: * **data:** wrap the response in a data field of an envelope object, and add other meta data to that wrapper. The default value is None -* **retries:** If the response is not correct, send again the request. The default number of retries is 3. -* **status_retries:** List of response status code that consider "not correct". The default values are [500, 502, 504] -* **propagate_headers:** Propagate the headers of the actual execution to the request. The default values is False +* **retries:** If the response is not correct, this specifies the amount of times it performs the request again. The default number of retries is 3. +* **status_retries:** List of response status codes that are considered "not correct". The default values are [500, 502, 504] +* **propagate_headers:** Propagate the headers of the current execution to the request. The default values is False ### Example @@ -79,7 +79,7 @@ pyms: ## Tracer -Add trace to all executions with [opentracing](https://github.com/opentracing-contrib/python-flask). This service +Add traces to all executions with [opentracing](https://github.com/opentracing-contrib/python-flask). This service solves the problem of [distributed tracing](https://microservices.io/patterns/observability/distributed-tracing.html) ### Installation @@ -90,7 +90,7 @@ You must install `pyms` with `pip install pyms[all]` or `pip install pyms[trace] The parameters you can add to your config are: -* **client:** set the client to use traces, The actual options are [Jaeger](https://github.com/jaegertracing/jaeger-client-python) and [Lightstep](https://github.com/lightstep/lightstep-tracer-python). The default value is jaeger. +* **client:** set the client that will receive the traces, The current options are [Jaeger](https://github.com/jaegertracing/jaeger-client-python) and [Lightstep](https://github.com/lightstep/lightstep-tracer-python). The default value is jaeger. * **host:** The url to send the data of traces. Check [this tutorial](https://opentracing.io/guides/python/quickstart/) to create your own server * **component_name:** The name of your application to show in Prometheus metrics @@ -109,7 +109,7 @@ pyms: Adds [Prometheus](https://prometheus.io/) metrics using the [Prometheus Client Library](https://github.com/prometheus/client_python). -At the moment, the next metrics are available: +The folowing metrics are currently available: - Incoming requests latency as a histogram - Incoming requests number as a counter, divided by HTTP method, endpoint and @@ -158,8 +158,8 @@ pyms: myvalue: 5 ``` -* Your service will be setted inside `ms` object in `flask.current_app` objetct. for example, with the last config, -you can print the next code: +* Your service will be instanced inside the `ms` object in `flask.current_app` object. For example, with the last config, +you could print the folowing code: ```python from flask import jsonify, current_app @@ -182,7 +182,7 @@ if __name__ == '__main__': app.run() ``` -This output in `http://localhost:5000/`: +This would be the output in `http://localhost:5000/`: ```json {"myvalue": 5, "myvalue2": 1} diff --git a/docs/structure.md b/docs/structure.md index 3d61791..1ce47b7 100644 --- a/docs/structure.md +++ b/docs/structure.md @@ -4,8 +4,8 @@ Module to read yaml or json configuration from a dictionary or a path. ### pyms/flask/app -With the function `create_app` initialize the Flask app, register [blueprints](http://flask.pocoo.org/docs/0.12/blueprints/) -and initialize all libraries such as Swagger, database, trace system, custom logger format, etc. +With the function `create_app` we initialize the Flask app, register [blueprints](http://flask.pocoo.org/docs/0.12/blueprints/) +and initialize all other libraries such as Swagger, database, trace system, custom logger format, etc. ### pyms/flask/services Integrations and wrappers over common libs like request, swagger, connexion or metrics. diff --git a/docs/tutorial_propagate_traces.md b/docs/tutorial_propagate_traces.md index 30cf85b..f229679 100644 --- a/docs/tutorial_propagate_traces.md +++ b/docs/tutorial_propagate_traces.md @@ -1,12 +1,12 @@ # Tutorial 1: Propagate Traces -With this tutorial you can solve the problem of the [distributed tracing](https://microservices.io/patterns/observability/distributed-tracing.html) +With this tutorial you can solve the problem of [distributed tracing](https://microservices.io/patterns/observability/distributed-tracing.html) You have applied the Microservice architecture pattern. Requests often span multiple services. Each service handles a request by performing one or more operations, e.g. database queries, publishes messages, etc. PyMS injects a unique request ID with [opentracing](https://github.com/opentracing-contrib/python-flask) and -passes the external request id to all services that are involved in handling the request with the [service request](services.md) +passes the external request id to all services that are involved in handling the current request with the [service request](services.md) ## 1. Simple Trace @@ -58,7 +58,7 @@ Run this script with: python main.py ``` -In other terminal, run this command: +In another terminal, run this command: ```bash curl 'http://localhost:5000/' @@ -120,10 +120,10 @@ if __name__ == '__main__': app.run(port=5001) ``` -Now, run this script and the first script, you will have the first in `http://localhost:5000/` and this new in +Now, run both this script and the first script. You should have the first one running on `http://localhost:5000/` and this new one on `http://localhost:5001/` -In other terminal, run this command: +In another terminal, run this command: ```bash curl 'http://localhost:5001/' @@ -134,7 +134,7 @@ curl 'http://localhost:5001/' ![Terminal](imgs/multiple-ms.png) -The second MS print this logs: +The second MS will print these logs: ```json {"message": "There are my headers: \nHost: localhost:5001\r\nUser-Agent: curl/7.58.0\r\nAccept: */*\r\n\r\n", @@ -177,15 +177,15 @@ And the first MS return: "parent": "c92e9babb0d002de"} ``` -As you can see, the two microservice have `"trace": "bb785b88d0456d69"`. +As you can see, both microservices have `"trace": "bb785b88d0456d69"`. ## Flow -You can see the flow of this requests in this diagram: +You can see the flow of these requests in this diagram: ![Distributed tracing](imgs/PyMSdistributedtracing.png) ## Code -You can check this example in See [this Github page](https://github.com/python-microservices/pyms/tree/master/examples/microservice_distribued_tracing) +You can check this example on [this Github page](https://github.com/python-microservices/pyms/tree/master/examples/microservice_distribued_tracing) From ccf2a1a457840ae6c7292ead21d14990db8ea41a Mon Sep 17 00:00:00 2001 From: avara1986 Date: Fri, 5 Jun 2020 20:55:07 +0200 Subject: [PATCH 02/13] fix typo --- docs/command_line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/command_line.md b/docs/command_line.md index e97fc34..4869884 100644 --- a/docs/command_line.md +++ b/docs/command_line.md @@ -1,6 +1,6 @@ # Commnand line -PyMS hcomes with some commands to make your developments easier: +PyMS comes with some commands to make your developments easier: ```bash pyms -h From 54543aa6d1ca4df059e9d51f07be7d575b114fbe Mon Sep 17 00:00:00 2001 From: avara1986 Date: Fri, 5 Jun 2020 20:58:42 +0200 Subject: [PATCH 03/13] Fix conflict --- docs/command_line.md | 152 ++++++++++++++++++++++++++++++++----------- 1 file changed, 114 insertions(+), 38 deletions(-) diff --git a/docs/command_line.md b/docs/command_line.md index 4869884..c37dfa4 100644 --- a/docs/command_line.md +++ b/docs/command_line.md @@ -1,69 +1,145 @@ -# Commnand line +# Encrypt Configuration -PyMS comes with some commands to make your developments easier: +## Configuration -```bash -pyms -h +# Method 1: Encrypt and decrypt with key file and Fernet + + +When you work in multiple environments: local, dev, testing, production... you must set critical configuration in your +variables, such as: + +config.yml, for local propose: +```yaml +pyms: + config: + DEBUG: true + TESTING: true + APPLICATION_ROOT : "" + SECRET_KEY: "gjr39dkjn344_!67#" + SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/my_schema ``` -Lists the options and help instructions to use this command: + +config_pro.yml, for production environment: +```yaml +pyms: + config: + DEBUG: true + TESTING: true + APPLICATION_ROOT : "" + SECRET_KEY: "gjr39dkjn344_!67#" + SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://important_user:****@localhost/my_schema +``` + +You can move this file to a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), +use [Vault](https://learn.hashicorp.com/vault) or encrypt the configuration with [AWS KMS](https://aws.amazon.com/en/kms/) + or [Google KMS](https://cloud.google.com/kms). We strongly recommend these of encrypting/decrypting your configuration, + but if you want a no vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt + and decrypt your variables. + +## 1. Generate a key +PyMS has a command line option to create a key file. This key is created with [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard). +You can run the next command in the terminal: ```bash -usage: main.py [-h] [-v VERBOSE] {encrypt,create-key,startproject} ... +pyms create-key +``` + +Then, type a password and it will create a file called `key.key`. This file contains a unique key. If you loose this file +and re-run the create command, the key hash will be different and your code encrypted with this key won't be able to be decrypted. -Python Microservices +Store this key in a secure site, and DO NOT COMMIT it to your repository. -optional arguments: - -h, --help show this help message and exit - -v VERBOSE, --verbose VERBOSE - Verbose -Commands: - Available commands +## 2. Add your key to your environment - {encrypt,create-key,startproject} - encrypt Encrypt a string - create-key Generate a Key to encrypt strings in config - startproject Generate a project from https://github.com/python- - microservices/microservices-template +Move your key, for example, to `mv key.key /home/my_user/keys/myproject.key` +then, store the in a environment variable with: + +```bash +export KEY_FILE=/home/my_user/keys/myproject.key ``` -## Start a project +## 3. Encrypt your information and store it in config + +Do you remember the example file `config_pro.yml`? Now you can encrypt and decrypt the information, you can run the command +`pyms encrypt [string]` to generate a crypt string, for example: -Command: ```bash -pyms startproject +pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' +>> Encrypted OK: b'gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA==' ``` -This command creates a project template like the one defined in [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold). -This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) +And store this string in your `config_pro.yml`: +```yaml +pyms: + crypt: + method: "fernet" + config: + DEBUG: true + TESTING: true + APPLICATION_ROOT : "" + SECRET_KEY: "gjr39dkjn344_!67#" + ENC_SQLALCHEMY_DATABASE_URI: gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA== +``` + +Do you see the difference between `ENC_SQLALCHEMY_DATABASE_URI` and `SQLALCHEMY_DATABASE_URI`? In the next step you +can find the answer -!!! warning - First, you must run `pip install cookiecutter==1.7.0` +## 4. Decrypt from your config file -## Create a key encrypt/decrypt file +Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS searches for your key file +in the `KEY_FILE` env variable and decrypts this value to store it in the same variable without the `enc_` prefix, +for example, + +```yaml +ENC_SQLALCHEMY_DATABASE_URI: gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA== +``` + +Will be stored as -Command: ```bash -pyms create-key +SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/my_schema ``` -Create a key file to encrypt strings in your configuration file. This key is created with [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard). -You can run the next command in the terminal. See [Encrypt/Decrypt Configuration](encrypt_decryt_configuration.md) -for more information +And you can access this var with `current_app.config["SQLALCHEMY_DATABASE_URI"]` + +# Method 2: Encrypt and decrypt with AWS KMS -## Encrypt a string +## 1. Configure AWS + +Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS uses boto3 and +aws cli to decrypt this value and store it in the same variable without the `enc_` prefix. + +First, configure aws your aws account credentials: -Command: ```bash -pyms encrypt [string] +aws configure ``` -Encrypt a string to use in your [configfile](configuration.md) +## 2. Encrypt with KMS + +Cypher a string with this command: ```bash -pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' ->> Encrypted OK: b'gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA==' +aws kms encrypt --key-id alias/prueba-avara --plaintext "mysql+mysqlconnector://important_user:****@localhost/my_schema" --query CiphertextBlob --output text +>> AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= + ``` -See [Encrypt/Decrypt Configuration](encrypt_decryt_configuration.md) for more information +## 3. Decrypt from your config file + +And put this string in your `config_pro.yml`: +```yaml +pyms: + crypt: + method: "aws_kms" + key_id: "alias/your-kms-key" + config: + DEBUG: true + TESTING: true + APPLICATION_ROOT : "" + SECRET_KEY: "gjr39dkjn344_!67#" + ENC_SQLALCHEMY_DATABASE_URI: "AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= +" +``` From 1c29be5132a3b623d8d623ae50422f9a5a778792 Mon Sep 17 00:00:00 2001 From: avara1986 Date: Fri, 5 Jun 2020 20:59:43 +0200 Subject: [PATCH 04/13] fix conflict --- docs/command_line.md | 152 +++++++-------------------- docs/encrypt_decryt_configuration.md | 46 ++++++++ 2 files changed, 84 insertions(+), 114 deletions(-) diff --git a/docs/command_line.md b/docs/command_line.md index c37dfa4..4869884 100644 --- a/docs/command_line.md +++ b/docs/command_line.md @@ -1,145 +1,69 @@ -# Encrypt Configuration +# Commnand line -## Configuration - -# Method 1: Encrypt and decrypt with key file and Fernet - - -When you work in multiple environments: local, dev, testing, production... you must set critical configuration in your -variables, such as: - -config.yml, for local propose: -```yaml -pyms: - config: - DEBUG: true - TESTING: true - APPLICATION_ROOT : "" - SECRET_KEY: "gjr39dkjn344_!67#" - SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/my_schema -``` - -config_pro.yml, for production environment: -```yaml -pyms: - config: - DEBUG: true - TESTING: true - APPLICATION_ROOT : "" - SECRET_KEY: "gjr39dkjn344_!67#" - SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://important_user:****@localhost/my_schema -``` - -You can move this file to a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), -use [Vault](https://learn.hashicorp.com/vault) or encrypt the configuration with [AWS KMS](https://aws.amazon.com/en/kms/) - or [Google KMS](https://cloud.google.com/kms). We strongly recommend these of encrypting/decrypting your configuration, - but if you want a no vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt - and decrypt your variables. - -## 1. Generate a key -PyMS has a command line option to create a key file. This key is created with [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard). -You can run the next command in the terminal: +PyMS comes with some commands to make your developments easier: ```bash -pyms create-key +pyms -h ``` +Lists the options and help instructions to use this command: -Then, type a password and it will create a file called `key.key`. This file contains a unique key. If you loose this file -and re-run the create command, the key hash will be different and your code encrypted with this key won't be able to be decrypted. - -Store this key in a secure site, and DO NOT COMMIT it to your repository. +```bash +usage: main.py [-h] [-v VERBOSE] {encrypt,create-key,startproject} ... +Python Microservices -## 2. Add your key to your environment +optional arguments: + -h, --help show this help message and exit + -v VERBOSE, --verbose VERBOSE + Verbose -Move your key, for example, to `mv key.key /home/my_user/keys/myproject.key` +Commands: + Available commands -then, store the in a environment variable with: + {encrypt,create-key,startproject} + encrypt Encrypt a string + create-key Generate a Key to encrypt strings in config + startproject Generate a project from https://github.com/python- + microservices/microservices-template -```bash -export KEY_FILE=/home/my_user/keys/myproject.key ``` -## 3. Encrypt your information and store it in config - -Do you remember the example file `config_pro.yml`? Now you can encrypt and decrypt the information, you can run the command -`pyms encrypt [string]` to generate a crypt string, for example: +## Start a project +Command: ```bash -pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' ->> Encrypted OK: b'gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA==' +pyms startproject ``` -And store this string in your `config_pro.yml`: -```yaml -pyms: - crypt: - method: "fernet" - config: - DEBUG: true - TESTING: true - APPLICATION_ROOT : "" - SECRET_KEY: "gjr39dkjn344_!67#" - ENC_SQLALCHEMY_DATABASE_URI: gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA== -``` - -Do you see the difference between `ENC_SQLALCHEMY_DATABASE_URI` and `SQLALCHEMY_DATABASE_URI`? In the next step you -can find the answer +This command creates a project template like the one defined in [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold). +This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) -## 4. Decrypt from your config file +!!! warning + First, you must run `pip install cookiecutter==1.7.0` -Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS searches for your key file -in the `KEY_FILE` env variable and decrypts this value to store it in the same variable without the `enc_` prefix, -for example, - -```yaml -ENC_SQLALCHEMY_DATABASE_URI: gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA== -``` - -Will be stored as +## Create a key encrypt/decrypt file +Command: ```bash -SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/my_schema +pyms create-key ``` -And you can access this var with `current_app.config["SQLALCHEMY_DATABASE_URI"]` - -# Method 2: Encrypt and decrypt with AWS KMS +Create a key file to encrypt strings in your configuration file. This key is created with [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard). +You can run the next command in the terminal. See [Encrypt/Decrypt Configuration](encrypt_decryt_configuration.md) +for more information -## 1. Configure AWS - -Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS uses boto3 and -aws cli to decrypt this value and store it in the same variable without the `enc_` prefix. - -First, configure aws your aws account credentials: +## Encrypt a string +Command: ```bash -aws configure +pyms encrypt [string] ``` -## 2. Encrypt with KMS - -Cypher a string with this command: +Encrypt a string to use in your [configfile](configuration.md) ```bash -aws kms encrypt --key-id alias/prueba-avara --plaintext "mysql+mysqlconnector://important_user:****@localhost/my_schema" --query CiphertextBlob --output text ->> AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= - +pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' +>> Encrypted OK: b'gAAAAABeSwBJv43hnGAWZOY50QjBX6uGLxUb3Q6fcUhMxKspIVIco8qwwZvxRg930uRlsd47isroXzkdRRnb4-x2dsQMp0dln8Pm2ySHH7TryLbQYEFbSh8RQK7zor-hX6gB-JY3uQD3IMtiVKx9AF95D6U4ydT-OA==' ``` -## 3. Decrypt from your config file - -And put this string in your `config_pro.yml`: -```yaml -pyms: - crypt: - method: "aws_kms" - key_id: "alias/your-kms-key" - config: - DEBUG: true - TESTING: true - APPLICATION_ROOT : "" - SECRET_KEY: "gjr39dkjn344_!67#" - ENC_SQLALCHEMY_DATABASE_URI: "AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= -" -``` +See [Encrypt/Decrypt Configuration](encrypt_decryt_configuration.md) for more information diff --git a/docs/encrypt_decryt_configuration.md b/docs/encrypt_decryt_configuration.md index 66f11f3..95761ff 100644 --- a/docs/encrypt_decryt_configuration.md +++ b/docs/encrypt_decryt_configuration.md @@ -2,6 +2,9 @@ ## Configuration +# Method 1: Encrypt and decrypt with key file and Fernet + + When you work in multiple environments: local, dev, testing, production... you must set critical configuration in your variables, such as: @@ -70,6 +73,8 @@ pyms encrypt 'mysql+mysqlconnector://important_user:****@localhost/my_schema' And store this string in your `config_pro.yml`: ```yaml pyms: + crypt: + method: "fernet" config: DEBUG: true TESTING: true @@ -98,3 +103,44 @@ SQLALCHEMY_DATABASE_URI: mysql+mysqlconnector://user_of_db:user_of_db@localhost/ ``` And you can access this var with `current_app.config["SQLALCHEMY_DATABASE_URI"]` + +# Method 2: Encrypt and decrypt with AWS KMS + +## 1. Configure AWS + +Pyms knows if a variable is encrypted if this var start with the prefix `enc_` or `ENC_`. PyMS uses boto3 and +aws cli to decrypt this value and store it in the same variable without the `enc_` prefix. + +First, configure aws your aws account credentials: + +```bash +aws configure +``` + +## 2. Encrypt with KMS + +Cypher a string with this command: + +```bash +aws kms encrypt --key-id alias/prueba-avara --plaintext "mysql+mysqlconnector://important_user:****@localhost/my_schema" --query CiphertextBlob --output text +>> AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= + +``` + +## 3. Decrypt from your config file + +And put this string in your `config_pro.yml`: +```yaml +pyms: + crypt: + method: "aws_kms" + key_id: "alias/your-kms-key" + config: + DEBUG: true + TESTING: true + APPLICATION_ROOT : "" + SECRET_KEY: "gjr39dkjn344_!67#" + ENC_SQLALCHEMY_DATABASE_URI: "AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= +" +``` + From 9af9f84fdd3884300373b131dc6da2931f2d82ca Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:58:37 +0200 Subject: [PATCH 05/13] Update docs/configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index ca21ba8..2bc350a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -83,7 +83,7 @@ our `ms` object will have an attribute `requests` that is a instance of our serv ## pyms - config block This section contains all keywords used for general [Flask Configuration Handling](http://flask.pocoo.org/docs/1.0/config/), along -with our constants for the different the enviroments (local configuration, staging configuration...). Keep in mind that +with our constants for the different enviroments (local configuration, staging configuration...). Keep in mind that a Flask app configuration needs the keywords to be declared as uppercase. If you defined a variable like `app_name`, you will be able to retrieve it this with `current_app.config["APP_NAME"]` @@ -166,4 +166,4 @@ spec: name: my-microservice-configmap ``` -See [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial \ No newline at end of file +See [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial From 98002e709d106d8a8dccacf17879fca56e282e4f Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:58:48 +0200 Subject: [PATCH 06/13] Update docs/configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 2bc350a..76647d8 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -135,7 +135,7 @@ API = Api( ## Looking for Configuration file with Kubernetes Configmaps -By default, a Microservice class searches for a config.yml in the same path. You can set a different route or set a json file. +By default, the Microservice class searches for a config.yml in the same path. You can set a different route or set a json file. To change this path, you must define a environment variable `CONFIGMAP_FILE`. This way of looking for the configuration is useful when you work with Docker and Kubernetes. For example, you could integrate From 0a4e34b790c4144abf6cf56f050cfb4020c80b68 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:58:58 +0200 Subject: [PATCH 07/13] Update docs/configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 76647d8..786cce5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -136,7 +136,7 @@ API = Api( ## Looking for Configuration file with Kubernetes Configmaps By default, the Microservice class searches for a config.yml in the same path. You can set a different route or set a json file. -To change this path, you must define a environment variable `CONFIGMAP_FILE`. +To change this path, you must define an environment variable called `CONFIGMAP_FILE`. This way of looking for the configuration is useful when you work with Docker and Kubernetes. For example, you could integrate a configmap of Kubernetes, with this microservice and a deployment with: From 061c18cc12718abaf1edfee6653ec65c35fcab49 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:59:09 +0200 Subject: [PATCH 08/13] Update docs/encrypt_decryt_configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/encrypt_decryt_configuration.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/encrypt_decryt_configuration.md b/docs/encrypt_decryt_configuration.md index e3341f6..4bd42a8 100644 --- a/docs/encrypt_decryt_configuration.md +++ b/docs/encrypt_decryt_configuration.md @@ -32,7 +32,7 @@ pyms: You can move this file to a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), use [Vault](https://learn.hashicorp.com/vault) or encrypt the configuration with [AWS KMS](https://aws.amazon.com/en/kms/) - or [Google KMS](https://cloud.google.com/kms). We strongly recommend these of encrypting/decrypting your configuration, + or [Google KMS](https://cloud.google.com/kms). We strongly recommend these way of encrypting/decrypting your configuration, but if you want a no vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt and decrypt your variables. @@ -144,4 +144,3 @@ pyms: " ``` - From be48eeee7c3f5247d36268e50bb550514d7ff249 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:59:16 +0200 Subject: [PATCH 09/13] Update docs/encrypt_decryt_configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/encrypt_decryt_configuration.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/encrypt_decryt_configuration.md b/docs/encrypt_decryt_configuration.md index 4bd42a8..75d183b 100644 --- a/docs/encrypt_decryt_configuration.md +++ b/docs/encrypt_decryt_configuration.md @@ -33,7 +33,7 @@ pyms: You can move this file to a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), use [Vault](https://learn.hashicorp.com/vault) or encrypt the configuration with [AWS KMS](https://aws.amazon.com/en/kms/) or [Google KMS](https://cloud.google.com/kms). We strongly recommend these way of encrypting/decrypting your configuration, - but if you want a no vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt + but if you don't want a vendor locking option or you don't have the resources to use these methods, we provide a way to encrypt and decrypt your variables. ## 1. Generate a key @@ -143,4 +143,3 @@ pyms: ENC_SQLALCHEMY_DATABASE_URI: "AQICAHiALhLQv4eW8jqUccFSnkyDkBAWLAm97Lr2qmdItkUCIAF+P4u/uqzu8KRT74PsnQXhAAAAoDCBnQYJKoZIhvcNAQcGoIGPMIGMAgEAMIGGBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDPo+k3ZxoI9XVKtHgQIBEIBZmp7UUVjNWd6qKrLVK8oBNczY0CfLH6iAZE3UK5Ofs4+nZFi0PL3SEW8M15VgTpQoC/b0YxDPHjF0V6NHUJcWirSAqKkP5Sz5eSTk91FTuiwDpvYQ2q9aY6w= " ``` - From 48935fd5dd60fb2e8ea9f1bcf96fccad04fc8108 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:59:23 +0200 Subject: [PATCH 10/13] Update docs/ms_class.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/ms_class.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ms_class.md b/docs/ms_class.md index e36b4da..795d2f3 100644 --- a/docs/ms_class.md +++ b/docs/ms_class.md @@ -32,7 +32,7 @@ pyms: ``` Check the [Configuration](configuration.md) section to learn how to create a configuration file. -The `Microservice` class searches for a `config.yml` in the directory you pass in `path` parameter or looks fot the file in +The `Microservice` class searches for a `config.yml` in the directory you pass in `path` parameter or looks for the file in `CONFIGMAP_FILE` env var. Each keyword in our configuration block, can be accessed in our Microservice object through the attribute `config`. @@ -97,4 +97,4 @@ The Microservice class initializes libraries and other process in the following ``` -Check for more examples in [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) \ No newline at end of file +Check for more examples in [this Github page](https://github.com/python-microservices/pyms/tree/master/examples) From 69425d963e65ff173ea48b9b089b972c4d2c5c01 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:59:31 +0200 Subject: [PATCH 11/13] Update docs/quickstart.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 06b0896..a9ae4d5 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -51,7 +51,7 @@ PyMS has a command line option to create a project template like [Microservices This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template) !!! warning - Fist, you must run `pip install cookiecutter==1.7.0` + First, you must run `pip install cookiecutter==1.7.0` ## Installation @@ -84,4 +84,4 @@ Choose from 1, 2, 3, 4, 5, 6 [1]: When you finish introducing the options, a project will be created in `[project_folder]` folder -See [Configuration](configuration.md), [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial \ No newline at end of file +See [Configuration](configuration.md), [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial From 7b07ffadbe892ef0215d2feba35c84aa8d96f632 Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 11:59:59 +0200 Subject: [PATCH 12/13] Update docs/encrypt_decryt_configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/encrypt_decryt_configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/encrypt_decryt_configuration.md b/docs/encrypt_decryt_configuration.md index 75d183b..b608c3d 100644 --- a/docs/encrypt_decryt_configuration.md +++ b/docs/encrypt_decryt_configuration.md @@ -54,7 +54,7 @@ Store this key in a secure site, and DO NOT COMMIT it to your repository. Move your key, for example, to `mv key.key /home/my_user/keys/myproject.key` -then, store the in a environment variable with: +then, store the key in a environment variable with: ```bash export KEY_FILE=/home/my_user/keys/myproject.key From bf95b55d534eebd535b70c7a03d1a83b3e6cc05d Mon Sep 17 00:00:00 2001 From: Alberto Vara Date: Sat, 6 Jun 2020 12:00:14 +0200 Subject: [PATCH 13/13] Update docs/configuration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Àlex Pérez --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 786cce5..016f596 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -85,7 +85,7 @@ our `ms` object will have an attribute `requests` that is a instance of our serv This section contains all keywords used for general [Flask Configuration Handling](http://flask.pocoo.org/docs/1.0/config/), along with our constants for the different enviroments (local configuration, staging configuration...). Keep in mind that a Flask app configuration needs the keywords to be declared as uppercase. If you defined a variable like `app_name`, -you will be able to retrieve it this with `current_app.config["APP_NAME"]` +you will be able to retrieve it with `current_app.config["APP_NAME"]` ## Import Configuration