-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgitlab-template.yaml
More file actions
677 lines (677 loc) · 18.8 KB
/
gitlab-template.yaml
File metadata and controls
677 lines (677 loc) · 18.8 KB
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
apiVersion: template.openshift.io/v1
kind: Template
labels:
createdBy: gitlab-ce-template
metadata:
annotations:
description: "GitLab. Collaboration and source control management: code, test,
and deploy together! \n\n GitLab requries that the serviceaccount for the main
GitLab app be added to the anyuid security context. The service account name
is: <application name>-user"
iconClass: icon-gitlab
tags: instant-app,gitlab,VCS,ci-cd
name: gitlab-ce
objects:
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
spec:
tags:
- from:
kind: DockerImage
name: gitlab/gitlab-ce:12.4.8-ce.0
name: gitlab-12.4.8
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-runner
spec:
tags:
- from:
kind: DockerImage
name: gitlab/gitlab-runner:v12.7.0
name: gitlab-runner-v12.7.0
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-redis
spec:
tags:
- from:
kind: DockerImage
name: redis:3.2.3-alpine
name: 3.2.3
- apiVersion: v1
kind: ServiceAccount
metadata:
name: ${APPLICATION_NAME}-user
- apiVersion: v1
kind: ServiceAccount
metadata:
name: ${APPLICATION_NAME}-runner-user
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
spec:
replicas: 1
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}
strategy:
recreateParams: {}
resources: {}
type: Recreate
template:
metadata:
labels:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}
spec:
containers:
- env:
- name: GITLAB_OMNIBUS_CONFIG
valueFrom:
configMapKeyRef:
key: gitlab.rb
name: gitlab-config
image: gitlab-ce
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /-/liveness
port: 80
scheme: HTTP
initialDelaySeconds: 180
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: gitlab-ce
ports:
- containerPort: 22
protocol: TCP
- containerPort: 80
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /-/readiness
port: 80
scheme: HTTP
initialDelaySeconds: 120
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: ${GITLAB_MAX_CPU}
memory: ${GITLAB_MAX_MEMORY}
requests:
cpu: 500m
memory: 1Gi
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /etc/gitlab
name: gitlab-ce-volume-1
- mountPath: /gitlab-data
name: gitlab-ce-volume-2
- mountPath: /var/opt/gitlab/gitlab-rails/shared/artifacts
name: gitlab-ce-volume-3
- mountPath: /var/opt/gitlab/gitlab-rails/shared/pages
name: gitlab-ce-volume-4
dnsPolicy: ClusterFirst
restartPolicy: Always
serviceAccount: ${APPLICATION_NAME}-user
terminationGracePeriodSeconds: 30
volumes:
- name: gitlab-ce-volume-1
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-etc
- name: gitlab-ce-volume-2
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-data
- name: gitlab-ce-volume-3
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-artifacts
- name: gitlab-ce-volume-4
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-pages
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- gitlab-ce
from:
kind: ImageStreamTag
name: ${APPLICATION_NAME}:gitlab-12.4.8
type: ImageChange
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-runner
spec:
replicas: ${GITLAB_RUNNER_REPLICAS}
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-runner
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
labels:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-runner
spec:
containers:
- command:
- /bin/bash
- /scripts/entrypoint
env:
- name: REGISTRATION_TOKEN
value: ${GITLAB_RUNNER_TOKEN}
- name: REGISTER_LOCKED
value: "false"
- name: KUBERNETES_PRIVILEGED
value: "true"
- name: KUBERNETES_IMAGE
value: ubuntu:16.04
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: gitlab-runner
imagePullPolicy: IfNotPresent
name: gitlab-runner
resources: {}
securityContext:
privileged: true
runAsUser: 0
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/gitlab-runner
name: gitlab-runner-1
- mountPath: /home/gitlab-runner
name: gitlab-runner-2
- mountPath: /scripts
name: scripts
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: ${APPLICATION_NAME}-runner-user
serviceAccountName: ${APPLICATION_NAME}-runner-user
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: gitlab-runner-1
- emptyDir: {}
name: gitlab-runner-2
- configMap:
defaultMode: 420
name: gitlab-runner
name: scripts
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- gitlab-runner
from:
kind: ImageStreamTag
name: ${APPLICATION_NAME}-runner:gitlab-runner-v12.7.0
type: ImageChange
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-redis
spec:
replicas: 1
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-redis
strategy:
recreateParams: {}
resources: {}
type: Recreate
template:
metadata:
labels:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-redis
spec:
containers:
- args:
- exec redis-server
command:
- /bin/sh
- -ec
image: gitlab-ce-redis
imagePullPolicy: IfNotPresent
name: gitlab-ce-redis
ports:
- containerPort: 6379
protocol: TCP
resources:
limits:
cpu: "1"
memory: 512Mi
requests:
cpu: 100m
memory: 300Mi
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /data
name: gitlab-ce-volume-4
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: gitlab-ce-volume-4
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-redis-data
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- gitlab-ce-redis
from:
kind: ImageStreamTag
name: ${APPLICATION_NAME}-redis:3.2.3
type: ImageChange
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-postgresql
spec:
replicas: 1
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-postgresql
strategy:
recreateParams:
post:
execNewPod:
command:
- /usr/bin/scl
- enable
- rh-postgresql96
- export PGPASSWORD='${POSTGRESQL_ADMIN_PASSWORD}'; psql -h '${APPLICATION_NAME}-postgresql'
-U postgres -d ${POSTGRESQL_DATABASE} -c 'CREATE EXTENSION IF NOT EXISTS
pg_trgm;'
containerName: gitlab-ce-postgresql
env:
- name: HOME
value: /var/lib/pgsql
- name: PGDATA
value: /var/lib/pgsql/data/userdata
- name: CONTAINER_SCRIPTS_PATH
value: /usr/share/container-scripts/postgresql
failurePolicy: Retry
resources: {}
type: Recreate
template:
metadata:
labels:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-postgresql
spec:
containers:
- env:
- name: POSTGRESQL_USER
value: ${POSTGRESQL_USER}
- name: POSTGRESQL_PASSWORD
value: ${POSTGRESQL_PASSWORD}
- name: POSTGRESQL_DATABASE
value: ${POSTGRESQL_DATABASE}
- name: POSTGRESQL_ADMIN_PASSWORD
value: ${POSTGRESQL_ADMIN_PASSWORD}
image: gitlab-ce-postgresql
imagePullPolicy: IfNotPresent
livenessProbe:
initialDelaySeconds: 30
tcpSocket:
port: 5432
timeoutSeconds: 1
name: gitlab-ce-postgresql
ports:
- containerPort: 5432
protocol: TCP
readinessProbe:
exec:
command:
- /bin/sh
- -i
- -c
- psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c
'SELECT 1'
initialDelaySeconds: 5
timeoutSeconds: 1
resources:
limits:
cpu: "1"
memory: 512Mi
requests:
cpu: "1"
memory: 512Mi
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /var/lib/pgsql/data
name: gitlab-ce-volume-3
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: gitlab-ce-volume-3
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-postgresql
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- gitlab-ce-postgresql
from:
kind: ImageStreamTag
name: postgresql:10
namespace: openshift
type: ImageChange
- apiVersion: v1
kind: Service
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
spec:
ports:
- name: 22-ssh
port: 22
protocol: TCP
targetPort: 22
- name: 80-http
port: 80
protocol: TCP
targetPort: 80
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-redis
spec:
ports:
- name: 6379-redis
port: 6379
protocol: TCP
targetPort: 6379
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-redis
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}-postgresql
spec:
ports:
- name: 5432-postgresql
port: 5432
protocol: TCP
targetPort: 5432
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}-postgresql
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-redis-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${REDIS_VOL_SIZE}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-etc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${ETC_VOL_SIZE}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${GITLAB_DATA_VOL_SIZE}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-artifacts
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${GITLAB_ARTIFACTS_VOL_SIZE}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-pages
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${GITLAB_PAGES_VOL_SIZE}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${APPLICATION_NAME}-postgresql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${POSTGRESQL_VOL_SIZE}
- apiVersion: v1
kind: Route
metadata:
labels:
app: ${APPLICATION_NAME}
name: ${APPLICATION_NAME}
spec:
host: ${APPLICATION_HOSTNAME}
port:
targetPort: 80-http
to:
kind: Service
name: ${APPLICATION_NAME}
- apiVersion: v1
kind: ConfigMap
metadata:
name: gitlab-config
data:
gitlab.rb: |
external_url "http://${APPLICATION_HOSTNAME}/"
postgresql['enable']=false
gitlab_rails['db_host'] = '${APPLICATION_NAME}-postgresql'
gitlab_rails['db_password']='${POSTGRESQL_PASSWORD}'
gitlab_rails['db_username']='${POSTGRESQL_USER}'
gitlab_rails['db_database']='${POSTGRESQL_DATABASE}'
redis['enable'] = false
gitlab_rails['redis_host']='${APPLICATION_NAME}-redis'
unicorn['worker_processes'] = ${UNICORN_WORKERS}
manage_accounts['enable'] = true
manage_storage_directories['manage_etc'] = false
gitlab_shell['auth_file'] = '/gitlab-data/ssh/authorized_keys'
git_data_dirs({ 'default' => { 'path' => '/gitlab-data/git-data' } })
gitlab_rails['shared_path'] = '/gitlab-data/shared'
gitlab_rails['uploads_directory'] = '/gitlab-data/uploads'
gitlab_ci['builds_directory'] = '/gitlab-data/builds'
prometheus_monitoring['enable'] = false
gitlab_rails['usage_ping_enabled'] = false
gitlab_rails['initial_shared_runners_registration_token'] = "${GITLAB_RUNNER_TOKEN}"
gitlab_rails['monitoring_whitelist'] = ['0.0.0.0/0']
- apiVersion: v1
kind: ConfigMap
metadata:
name: gitlab-runner
data:
entrypoint: |
#!/bin/bash
set -xe
cp /scripts/config.toml /etc/gitlab-runner/
# Register the runner
/entrypoint register --non-interactive \
--url http://${APPLICATION_NAME} \
--executor kubernetes
# Add docker.sock volumes
cat /scripts/volumes.toml >> /etc/gitlab-runner/config.toml
# Start the runner
/entrypoint run --user=gitlab-runner \
--working-directory=/home/gitlab-runner
volumes.toml: |2
[[runners.kubernetes.volumes.host_path]]
name = "docker-sock"
mount_path = "/var/run/docker.sock"
host_path = "/var/run/docker.sock"
config.toml: |
concurrent = 10
check_interval = 10
parameters:
- description: The name for the application. The service will be named like the application.
displayName: Application name.
name: APPLICATION_NAME
value: gitlab-ce
- description: Hostname for service routes. Set this in order to have the GitLab display
the correct clone urls.
displayName: Gitlab instance hostname
name: APPLICATION_HOSTNAME
required: true
- description: Password for the GitLab 'root' user. Must be at least 8 characters
long. Leave blank if you would rather configure the password using the website
during first use.
displayName: GitLab Root User Password
name: GITLAB_ROOT_PASSWORD
- description: The GitLab Runner Token
displayName: GitLab Runner Token
name: GITLAB_RUNNER_TOKEN
generate: expression
from: '[a-zA-Z0-9]{16}'
require: true
- description: Replicas for GitLab Runner
displayName: GitLab Runner Replicas
value: '1'
required: true
name: GITLAB_RUNNER_REPLICAS
- description: Username for PostgreSQL user that will be used for accessing the database.
displayName: PostgreSQL User
from: user[A-Z0-9]{3}
generate: expression
name: POSTGRESQL_USER
required: true
- description: Password for the PostgreSQL user.
displayName: PostgreSQL Password
from: '[a-zA-Z0-9]{16}'
generate: expression
name: POSTGRESQL_PASSWORD
required: true
- description: Password for the PostgreSQL Admin user.
displayName: PostgreSQL Admin User Password
from: '[a-zA-Z0-9]{16}'
generate: expression
name: POSTGRESQL_ADMIN_PASSWORD
required: true
- description: Name of the PostgreSQL database accessed.
displayName: PostgreSQL Database Name
name: POSTGRESQL_DATABASE
required: true
value: gitlabhq_production
- description: Number of Unicorn Workers to use per instance. Must be at least 2.
displayName: Number of Unicorn Workers
name: UNICORN_WORKERS
required: true
value: "2"
- description: "Maximum memory allowed for GitLab pod"
displayName: GitLab Max Memory
name: GITLAB_MAX_MEMORY
value: "4Gi"
required: true
- description: "Maximum CPU allowed for GitLab pod"
displayName: GitLab Max CPU
name: GITLAB_MAX_CPU
value: "1"
required: true
- description: Volume size for /etc
displayName: /etc/gitlab volume size
name: ETC_VOL_SIZE
value: 100Mi
- description: Volume size for GitLab data
displayName: GitLab data volume size
name: GITLAB_DATA_VOL_SIZE
value: 5Gi
- description: Volume size for GitLab artifacts
displayName: Artifacts volume size
name: GITLAB_ARTIFACTS_VOL_SIZE
value: 5Gi
- description: Volume size for GitLab pages
displayName: Pages volume size
name: GITLAB_PAGES_VOL_SIZE
value: 1Gi
- description: Volume size for postgresql data
displayName: postgresql volume size
name: POSTGRESQL_VOL_SIZE
value: 2Gi
- description: Volume size for redis data
displayName: redis volume size
name: REDIS_VOL_SIZE
value: 512Mi