Skip to content

Commit 07213af

Browse files
committed
Merge branch 'feature/update_doc' into develop
2 parents b844376 + 577cea2 commit 07213af

File tree

6 files changed

+125
-76
lines changed

6 files changed

+125
-76
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Content
2020
:maxdepth: 4
2121

2222
installation
23+
runinkubernetes
2324
quickstart
2425
structure
2526
configuration

docs/installation.rst

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,4 @@ Clone the project
88
99
Configure your project and the path of your MS. See :doc:`configuration </configuration>` section.
1010

11-
Configure your setup.py with your project information
12-
13-
14-
15-
Use MS with Docker
16-
------------------
17-
`Install docker <https://docs.docker.com/install/>`_
18-
19-
20-
Use MS with Kubernetes localy
21-
-----------------------------
22-
Configure your service.yaml (TODO: create docs to configure kubernetes service.yaml)
23-
24-
* Installing Kubernetes...
25-
26-
.. code-block:: bash
27-
28-
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
29-
30-
* Installing Minikube...
31-
32-
.. code-block:: bash
33-
34-
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
35-
36-
37-
Start minikube and set the environment of docker
38-
39-
.. code-block:: bash
40-
41-
minikube start
42-
eval $(minikube docker-env)
43-
kubectl config use-context minikube
44-
45-
If a shell isn't your friend. You could use kubernetes web panel to see your pods:
46-
47-
.. code-block:: bash
48-
49-
minikube dashboard
50-
51-
Create your image
52-
53-
.. code-block:: bash
54-
55-
docker build -t your-app:v1 .
56-
57-
Deploy your images localy:
58-
59-
.. code-block:: bash
60-
61-
kubectl create -f service.yaml
62-
minikube service your-app
63-
64-
65-
Clean your environment
66-
67-
.. code-block:: bash
68-
69-
kubectl delete service your-app
70-
kubectl delete deployment your-app
71-
docker rmi your-app:v1 -f
72-
minikube stop
73-
eval $(minikube docker-env -u)
74-
minikube delete
11+
Configure your setup.py with your project information

docs/runinkubernetes.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Run in kubernetes
2+
=================
3+
4+
Use MS with Docker
5+
------------------
6+
`Install docker <https://docs.docker.com/install/>`_
7+
8+
9+
Use MS with Kubernetes localy
10+
-----------------------------
11+
Configure your service.yaml (TODO: create docs to configure kubernetes service.yaml)
12+
13+
* Installing Kubernetes...
14+
15+
.. code-block:: bash
16+
17+
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
18+
19+
* Installing Minikube...
20+
21+
.. code-block:: bash
22+
23+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
24+
25+
26+
Start minikube and set the environment of docker
27+
28+
.. code-block:: bash
29+
30+
minikube start
31+
eval $(minikube docker-env)
32+
kubectl config use-context minikube
33+
34+
If a shell isn't your friend. You could use kubernetes web panel to see your pods:
35+
36+
.. code-block:: bash
37+
38+
minikube dashboard
39+
40+
Create your image
41+
42+
.. code-block:: bash
43+
44+
docker build -t template:v1 .
45+
46+
Deploy your images localy:
47+
48+
.. code-block:: bash
49+
50+
kubectl apply -f service.yaml
51+
minikube service template
52+
53+
54+
Clean your environment
55+
56+
.. code-block:: bash
57+
58+
kubectl delete template
59+
kubectl delete template
60+
docker rmi template:v1 -f
61+
minikube stop
62+
eval $(minikube docker-env -u)
63+
minikube delete

docs/structure.rst

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ You have a project with this structure:
66
.. code-block:: bash
77
88
manager.py
9+
requirements.txt
10+
requirements-tests.txt
11+
requirements-docker.txt
12+
setup.py
13+
tox.ini
14+
myms
15+
├ healthcheck
16+
│ └ healthcheck.py
17+
├ logger
18+
│ └ logger.py
19+
├ models
20+
│ └ __init__.py
21+
└ tracer
22+
└ main.py
923
project
1024
├ __init__.py
1125
├ config.py
1226
├ views
1327
│ ├ __init__.py
14-
│ ├ views.py
15-
│ └ healthcheck.py
28+
│ └ views.py
1629
├ models
1730
│ ├ __init__.py
1831
│ └ models.py
@@ -25,26 +38,48 @@ manager.py
2538
A Django style command line. Use this to start the application like:
2639

2740
.. code-block:: bash
41+
2842
python manage.py runserver
2943
3044
You can set the host and the port with:
3145

3246
.. code-block:: bash
47+
3348
python manage.py runserver -h 0.0.0.0 -p 8080
3449
50+
Common Structure
51+
----------------
52+
53+
myms/healthcheck/healthcheck.py
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
This views is usually used by Kubernetes, Eureka and other systems to check if our application is up and running
56+
57+
myms/logger/logger.py
58+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59+
Print logger in JSON format to send to server like Elasticsearch. Inject span traces in logger
60+
61+
myms/models/__init__.py
62+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63+
Initizalize `flask_sqlalchemy.SQLAlchemy object`
64+
65+
myms/tracer/main.py
66+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67+
Create an injector `flask_opentracing.FlaskTracer` to use in our projects
68+
69+
Structure of a project
70+
----------------------
71+
3572
project/__init__.py
36-
-------------------
73+
~~~~~~~~~~~~~~~~~~~
3774
This file init the project with the funcion `create_app`. Initialize the Flask app, register `blueprints <http://flask.pocoo.org/docs/0.12/blueprints/>`_
3875
and intialize all libraries like Swagger, database, the trace system...
3976

4077
project/config.py
41-
-----------------
78+
~~~~~~~~~~~~~~~~~
4279
See :doc:`configuration </configuration>` section
4380

4481
project/views
45-
-------------
82+
~~~~~~~~~~~~~
4683
use views.py or create your file. You must add after register the view blueprint in `project/views/__init__.py`.
4784

48-
project/views/healthcheck.py
49-
----------------------------
50-
This views is usually used by Kubernetes, Eureka and other systems to check if our application is up and running
85+

project/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _format_response(response: Text = "") -> Union[List, Dict]:
1010
return json.loads(response)
1111

1212

13-
class FlaskrTestCase(unittest.TestCase):
13+
class ProjectTestCase(unittest.TestCase):
1414

1515
def setUp(self):
1616
os.environ["ENVIRONMENT"] = "test"

service.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
# interno
12
kind: Service
23
apiVersion: v1
4+
kind: Service
35
metadata:
46
name: template
57
spec:
68
selector:
79
app: template
810
ports:
911
- protocol: TCP
10-
port: 80
12+
port: 5000
1113
targetPort: 5000
14+
type: LoadBalancer
15+
externalTrafficPolicy: "Local"
1216
---
1317
apiVersion: extensions/v1beta1
1418
kind: Deployment
@@ -23,7 +27,16 @@ spec:
2327
spec:
2428
containers:
2529
- name: template
26-
image: template:latest
30+
image: template:v1
2731
ports:
2832
- name: http
29-
containerPort: 5000
33+
containerPort: 5000
34+
---
35+
apiVersion: extensions/v1beta1
36+
kind: Ingress
37+
metadata:
38+
name: ingress
39+
spec:
40+
backend:
41+
serviceName: template
42+
servicePort: 5000

0 commit comments

Comments
 (0)