-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin-manifest.yaml
462 lines (423 loc) · 8.42 KB
/
admin-manifest.yaml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
apiVersion: apps/v1
kind: Deployment
metadata:
name: traefik
namespace: admin
labels:
app: traefik
network: admin
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
network: admin
spec:
serviceAccountName: traefik-ingress-controller
containers:
- name: traefik
image: traefik:v2.3
args:
- --api.insecure
- --accesslog
- --entrypoints.web.Address=:80
- --entrypoints.websecure.Address=:443
- --certificatesresolvers.myresolver.acme.tlschallenge
- --certificatesresolvers.myresolver.acme.email=${EMAIL}
- --certificatesresolvers.myresolver.acme.storage=acme.json
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --providers.kubernetescrd
- --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
ports:
- name: web
containerPort: 80
- name: websecure
containerPort: 443
---
## ADMIN WEB SERVER STACK
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: admin-web-server
namespace: admin
labels:
traefik: enabled
spec:
entryPoints:
- websecure
routes:
- match: Host(`admin.${DOMAIN_NAME}`) && (Path(`/{p:.+\..+}`) || Path(`/`))
kind: Rule
services:
- name: admin-web-server
namespace: admin
port: 80
tls:
certResolver: myresolver
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-web-server
namespace: admin
labels:
type: admin-web-server
spec:
template:
metadata:
namespace: admin
labels:
type: admin-web-server
spec:
containers:
- name: admin-web-server
image: ilyaskussainov/admin-webserver:latest
imagePullPolicy: Always
ports:
- containerPort: 80
selector:
matchLabels:
type: admin-web-server
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: admin-web-server
namespace: admin
labels:
type: admin-web-server
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
selector:
type: admin-web-server
---
## ADMIN APP SERVER STACK
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: admin-app-server
namespace: admin
labels:
traefik: enabled
spec:
entryPoints:
- websecure
routes:
- match: Host(`admin.${DOMAIN_NAME}`)
kind: Rule
services:
- name: admin-app-server
namespace: admin
port: 3000
tls:
certResolver: myresolver
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-app-server
namespace: admin
labels:
type: admin-app-server
network: admin
spec:
template:
metadata:
namespace: admin
labels:
type: admin-app-server
network: admin
spec:
serviceAccountName: admin-app
containers:
- name: admin-app-server
image: ilyaskussainov/admin-app:latest
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 5
ports:
- containerPort: 3000
env:
- name: SESSION_SECRET
value: verysecretstring
- name: REDIS_PORT
value: '6379'
- name: REDIS_HOST
value: "admin-session"
- name: DB_PASSWORD
value: password
- name: DB_USER
value: postgres
- name: DB_NAME
value: postgres
- name: DB_HOST
value: "admin-database"
- name: DOMAIN_NAME
value: "${DOMAIN_NAME}"
selector:
matchLabels:
type: admin-app-server
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: admin-app-server
namespace: admin
labels:
type: admin-app-server
spec:
type: ClusterIP
ports:
- port: 3000
targetPort: 3000
selector:
type: admin-app-server
---
### ADMIN DATABASE STACK
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: admin-pvc
namespace: admin
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-database
namespace: admin
labels:
type: admin-database
spec:
template:
metadata:
namespace: admin
labels:
type: admin-database
spec:
containers:
- name: admin-database
image: postgres
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command: ["psql", "-U", "postgres", "-d", "postgres", "-h", "127.0.0.1"]
initialDelaySeconds: 10
ports:
- containerPort: 5432
env:
- name: POSTGRES_PASSWORD
value: password
volumeMounts:
- mountPath: "/var/lib/postgresql/data"
name: admin-db-volume
subPath: postgres
volumes:
- name: admin-db-volume
persistentVolumeClaim:
claimName: admin-pvc
selector:
matchLabels:
type: admin-database
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: admin-database
namespace: admin
labels:
type: admin-database
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
type: admin-database
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: admin
name: admin-app
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-permission
subjects:
- kind: ServiceAccount
name: admin-app
namespace: admin
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: admin-session
namespace: admin
labels:
type: admin-session
spec:
template:
metadata:
namespace: admin
labels:
type: admin-session
spec:
containers:
- name: admin-session
image: redis:6.2-rc1-alpine3.12
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6379
selector:
matchLabels:
type: admin-session
replicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: admin-session
namespace: admin
labels:
type: admin-session
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
selector:
type: admin-session
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: traefik-policy
namespace: admin
spec:
podSelector:
matchLabels:
app: traefik
policyTypes:
- Ingress
- Egress
ingress:
- {}
egress:
- {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: db-policy
namespace: admin
spec:
podSelector:
matchLabels:
type: admin-database
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
type: admin-app-server
egress:
- {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: web-policy
namespace: admin
spec:
podSelector:
matchLabels:
type: admin-web-server
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: traefik
egress:
- {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: session-policy
namespace: admin
spec:
podSelector:
matchLabels:
type: admin-session
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
type: admin-app-server
egress:
- {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: app-policy
namespace: admin
spec:
podSelector:
matchLabels:
type: admin-app-server
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
type: satellite
podSelector:
matchLabels:
type: satellite-app-server
- podSelector:
matchLabels:
type: admin-session
- podSelector:
matchLabels:
type: admin-database
- podSelector:
matchLabels:
app: traefik
egress:
- {}