@@ -29,5 +29,67 @@ And a config file like this config.yml
2929my-minimal-microservice :
3030 APP_NAME : " Python Microservice"
3131` ` `
32+ See [Configuration](configuration.md) section to know how create a configuration file.
33+
34+ Each keyworkd in our configuration block, could be accessed in our Microservice object througth the attribute ` config`.
35+
36+ ` ` ` yaml
37+ # Config.yml
38+ example-config:
39+ APP_NAME: "Python Microservice"
40+ foo: "var"
41+ multiplevars:
42+ config1: "test1"
43+ config2: "test2"
44+
45+ ` ` `
46+ ` ` ` python
47+ #app.py
48+ from pyms.flask.app import Microservice
49+
50+ ms = Microservice(service="example-config", path=__file__)
51+ print(ms.config.APP_NAME)
52+ # >> "Python Microservice"
53+ print(ms.config.foo)
54+ # >> "bar"
55+ print(ms.config.multiplevars.config1)
56+ # >> "test1"
57+ print(ms.config.multiplevars.config2)
58+ # >> "test2"
59+ ` ` `
60+
61+
62+
63+ # Looking for Configuration file
64+ By default, Microservice class search a config.yml in the same path. You can set a diferent route or set a json file.
65+ To change this path, define a environment variable `CONFIGMAP_FILE`.
66+
67+ This way of search the configuration is useful when you work with Docker and Kubernetes. For example, you can integrate
68+ a configmap of Kubernetes, with this microservice and a deployment with :
69+
70+ ` ` ` yaml
71+ apiVersion: extensions/v1beta1
72+ kind: Deployment
73+ metadata:
74+ name: my-microservice
75+ spec:
76+ replicas: 1
77+ template:
78+ spec:
79+ containers:
80+ - name: my-microservice
81+ image: ...
82+ env:
83+ - name: CONFIGMAP_FILE
84+ value: "/usr/share/microservice/config.yaml"
85+
86+ volumeMounts:
87+ - mountPath: /usr/share/microservice
88+ name: ms-config-volume
89+ volumes:
90+ - name: ms-config-volume
91+ configMap:
92+ name: my-microservice-configmap
93+ ` ` `
3294
3395See more examples in TODO : add link
0 commit comments