-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment.yml
425 lines (393 loc) · 10.5 KB
/
deployment.yml
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
kind: ConfigMap
apiVersion: v1
metadata:
name: gitlab-omnibusconfig
namespace: namespace-name
data:
gitlab.rb: |
# Basic configuration
gitlab_rails['initial_root_password'] = File.read('/etc/secrets/rootpw')
gitlab_rails['gitlab_signup_enabled'] = false
gitlab_rails['lfs_enabled'] = true
# Main NGINX
external_url 'https://gitlab.domain.tld/'
letsencrypt['enable'] = false
nginx['listen_port'] = 80
nginx['listen_https'] = false
# PlantUML
nginx['custom_gitlab_server_config'] = "location /-/plantuml/ { \n proxy_cache off; \n proxy_pass http://gitlab-plantuml:8080/; \n}\n"
gitlab_rails['env'] = { 'PLANTUML_ENCODING' => 'deflate' }
# SSH
gitlab_rails['gitlab_shell_ssh_port'] = 2244
# Registry
registry_external_url 'https://docker.domain.tld'
registry_nginx['listen_port'] = 8888
registry_nginx['listen_https'] = false
# Pages
gitlab_pages['inplace_chroot'] = true
pages_external_url 'https://docs.domain.tld'
pages_nginx['listen_port'] = 7777
pages_nginx['listen_https'] = false
# External PGSQL
postgresql['enable'] = false
gitlab_rails['db_database'] = 'gitlab'
gitlab_rails['db_host'] = 'gitlab-db'
gitlab_rails['db_port'] = '5432'
gitlab_rails['db_username'] = 'gitlab'
gitlab_rails['db_password'] = File.read('/etc/secrets/dbpw')
# External Redis
redis['enable'] = false
gitlab_rails['redis_host'] = "gitlab-kvdb"
gitlab_rails['redis_port'] = 6379
gitlab_rails['redis_password'] = File.read('/etc/secrets/kvdbpw')
# Identity provider
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_saml_user'] = true
gitlab_rails['omniauth_providers'] = [
{
"name" => "saml",
"label" => "IDP Label",
"groups_attribute" => "groups",
"admin_groups" => ['admin'],
"args" => {
"assertion_consumer_service_url" => 'https://gitlab.domain.tld/users/auth/saml/callback',
"idp_cert"=> "PLACEHOLDER",
"idp_sso_target_url"=> 'https://auth.domain.tld/auth/realms/namespace-name/protocol/saml/clients/gitlab.domain.tld',
"issuer"=> 'gitlab.domain.tld',
"name_identifier_format"=> 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
"attribute_statements"=> {
"first_name"=> ['first_name'],
"last_name"=> ['last_name'],
"name"=> ['cn'],
"usernamerratice"=> ['cn'],
"email"=> ['email']
}
}
}
]
# SMTP Sendmail
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_reply_to'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = File.read('/etc/secrets/smtppw')
gitlab_rails['smtp_domain'] = "smtp.domain.tld"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
# Prometheus
prometheus_monitoring['enable'] = false
# Packages
gitlab_rails['packages_enabled'] = true
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: gitlab-db
namespace: namespace-name
spec:
selector:
matchLabels:
service: gitlab-db
template:
metadata:
labels:
service: gitlab-db
spec:
nodeSelector:
storageaccess: direct
volumes:
- name: gitlab-db
hostPath:
path: "/cluster/namespace-name/gitlab/db"
type: "DirectoryOrCreate"
containers:
- name: "gitlab-db"
image: "postgres:12.8"
env:
- name: POSTGRES_DATABASE
value: gitlab
- name: POSTGRES_USER
value: gitlab
- name: POSTGRES_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: gitlab-secrets
key: dbpw
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: gitlab-secrets
key: dbpw
volumeMounts:
- mountPath: "/var/lib/postgresql/data"
name: gitlab-db
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: gitlab-kvdb
namespace: namespace-name
spec:
selector:
matchLabels:
service: gitlab-kvdb
template:
metadata:
labels:
service: gitlab-kvdb
spec:
volumes:
- name: gitlab-kvdb
hostPath:
path: "/cluster/namespace-name/gitlab/kvdb"
type: "DirectoryOrCreate"
containers:
- name: "gitlab-kvdb"
image: "redis:latest"
args:
- --loglevel warning
- --requirepass $(REDIS_PASSWORD)
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: gitlab-secrets
key: kvdbpw
volumeMounts:
- mountPath: "/var/lib/redis"
name: gitlab-kvdb
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: gitlab
namespace: namespace-name
spec:
selector:
matchLabels:
service: gitlab
template:
metadata:
labels:
service: gitlab
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: performance
operator: In
values:
- high
volumes:
- name: gitlab-secrets
secret:
secretName: gitlab-secrets
- name: gitlab-omnibusconfig
configMap:
name: gitlab-omnibusconfig
- name: gitlab-data
hostPath:
path: "/cluster/namespace-name/gitlab/data"
type: "DirectoryOrCreate"
- name: gitlab-config
hostPath:
path: "/cluster/namespace-name/gitlab/config"
type: "DirectoryOrCreate"
- name: gitlab-pages
hostPath:
path: "/cluster/storage/shared/pages"
type: "DirectoryOrCreate"
- name: gitlab-packages
hostPath:
path: "/cluster/storage/namespace-name/gitlab/packages"
type: "DirectoryOrCreate"
- name: gitlab-logs
hostPath:
path: "/cluster/storage/namespace-name/gitlab/logs"
type: "DirectoryOrCreate"
- name: gitlab-lfs
hostPath:
path: "/cluster/storage/namespace-name/gitlab/lfs"
type: "DirectoryOrCreate"
- name: gitlab-registry
hostPath:
path: "/cluster/storage/namespace-name/gitlab/registry"
type: "DirectoryOrCreate"
- name: gitlab-backups
hostPath:
path: "/cluster/storage/namespace-name/gitlab/backups"
type: "DirectoryOrCreate"
containers:
- name: "gitlab"
image: "gitlab/gitlab-ce:14.1.5-ce.0"
env:
- name: GITLAB_OMNIBUS_CONFIG
value: "from_file('/etc/gitlab/omnibus/gitlab.rb')"
volumeMounts:
- mountPath: "/etc/gitlab/omnibus"
name: "gitlab-omnibusconfig"
- mountPath: "/var/opt/gitlab"
name: "gitlab-data"
- mountPath: "/var/log/gitlab"
name: "gitlab-logs"
- mountPath: "/etc/gitlab"
name: "gitlab-config"
- mountPath: "/var/opt/gitlab/gitlab-rails/shared/lfs-objects"
name: "gitlab-lfs"
- mountPath: "/var/opt/gitlab/gitlab-rails/shared/registry"
name: "gitlab-registry"
- mountPath: "/var/opt/gitlab/gitlab-rails/shared/pages"
name: "gitlab-pages"
- mountPath: "/var/opt/gitlab/gitlab-rails/shared/packages"
name: "gitlab-packages"
- mountPath: "/var/opt/gitlab/backups"
name: "gitlab-backups"
- mountPath: "/etc/secrets"
readOnly: true
name: "gitlab-secrets"
ports:
- name: ssh
containerPort: 22
- name: http
containerPort: 80
- name: http-docker
containerPort: 8888
- name: http-docs
containerPort: 7777
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: gitlab-plantuml
namespace: namespace-name
spec:
selector:
matchLabels:
service: gitlab-plantuml
template:
metadata:
labels:
service: gitlab-plantuml
spec:
containers:
- name: "gitlab-plantuml"
image: "plantuml/plantuml-server:tomcat-v1.2021.0"
ports:
- name: main
containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: gitlab-db
namespace: namespace-name
spec:
selector:
service: gitlab-db
ports:
- protocol: TCP
port: 5432
name: db
---
kind: Service
apiVersion: v1
metadata:
name: gitlab-kvdb
namespace: namespace-name
spec:
selector:
service: gitlab-kvdb
ports:
- protocol: TCP
port: 6379
name: db
---
kind: Service
apiVersion: v1
metadata:
name: gitlab
namespace: namespace-name
spec:
selector:
service: gitlab
ports:
- protocol: TCP
port: 80
name: http
- protocol: TCP
port: 8888
name: http-docker
- protocol: TCP
port: 7777
name: http-docs
---
kind: Service
apiVersion: v1
metadata:
name: gitlab-ssh
namespace: namespace-name
spec:
selector:
service: gitlab
type: NodePort
ports:
- protocol: TCP
port: 22
targetPort: 22
nodePort: 2244
name: ssh
---
kind: Service
apiVersion: v1
metadata:
name: gitlab-plantuml
namespace: namespace-name
spec:
selector:
service: gitlab-plantuml
ports:
- protocol: TCP
port: 8080
name: main
---
kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
name: gitlab
namespace: namespace-name
annotations:
kubernetes.io/ingress.class: traefik
traefik.frontend.passHostHeader: "false"
spec:
rules:
- host: gitlab.domain.tld
http:
paths:
- path: /
backend:
serviceName: gitlab
servicePort: http
- host: docker.domain.tld
http:
paths:
- path: /
backend:
serviceName: gitlab
servicePort: http-docker
- host: docs.domain.tld
http:
paths:
- path: /
backend:
serviceName: gitlab
servicePort: http-docs