-
Notifications
You must be signed in to change notification settings - Fork 7
/
02-writing servies.slide
152 lines (95 loc) · 2.62 KB
/
02-writing servies.slide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Production-ready microservices with Go and Kubernetes
Part 1
09:00 31 May 2017
Elena Grahovac
Senior Go Developer, DCMN
elena@grahovac.me
@webdeva
Alexey Palazhchenko
Lead Gopher, Golang Moscow
@paaleksey
* These slides
- https://goo.gl/K3sjqS
- or https://talks.godoc.org/github.com/k8s-community/k8s-workshop-eu/02-writing%20servies.slide#1
- https://github.com/k8s-community/k8s-workshop-eu
* Production readiness
* Four-layer model of the microservice ecosystem
.image production-readiness.png 450 _
.caption by Susan J. Fowler, Production-Ready Microservices
* Production readiness and Kubernetes
.image production-readiness-kubernetes.png 450 _
* Standartization and requirements
* Standartization
- stability
- reliability
- scalability
- security
- fault tolerance
- monitoring
- documentation
- service-level agreements (SLA)
- some specific requirements
* Source code lifecycle
.image source-code-lifecycle.png 450 _
* Source code lifecycle at the workshop
.image source-code-lifecycle-workshop.png 450 _
* The Twelve-Factor App
.link https://12factor.net
- codebase revision control
- configuration
- service-based model
- stateless
- startup and shutdown
- logs
- stages and pipelines: build, test, release, run
- staging and prod similarity
* Codebase
* Codebase
- branch model
- events and triggers
* Events and triggers
events:
- commit
- push
- pull request
- merge
triggers:
- run tests and security checks
- build and push image
- start release process
- create tags
* Step 1. Prepare a repo
- create a repo on GitHub
- go get it
- create a branch
* Step 2. Prepare linters and pre-commit hooks (optional)
- gometalinter:
.link https://github.com/alecthomas/gometalinter
- pre-commit:
.link https://pre-commit.com
.link https://github.com/troian/pre-commit-golang
- on-save actions / file watchers:
.link https://code.visualstudio.com/docs/languages/go
.link https://www.jetbrains.com/help/go/settings-tools-file-watchers.html
* Step 3. Write the simplest service
* Step 4. Add a logger
* Step 5. Add a router
- download a dependency: go get -u -v github.com/gorilla/mux
* Step 6. Move handlers to a separated package
* Step 7. Write tests
* Step 8. Configuration
* Define CI/CD pipeline
* Possible deployment pipeline
.image cicd.png 350 _
* Deployment pipeline for the workshop
.image workshop-process.png 450 _
* Step 9. Makefile
* Step 10. Versioning
* Step 11. Health schecks
* Step 12. Graceful shutdown
* If you use Windows it might be a little bit tricky
* Step 13. Vendoring
- install go dep
.link https://github.com/golang/dep
* Step 14. Dockerfile
* Step 15. Prepare Kubernetes configuration