forked from BCDevOps/sonarqube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sonarqube-postgresql-template.yaml
470 lines (457 loc) · 13.1 KB
/
sonarqube-postgresql-template.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
463
464
465
466
467
468
469
470
apiVersion: v1
kind: Template
message: "Login to SonarQube with the default admin user: admin/admin"
metadata:
annotations:
description: The SonarQube OpenShift template
tags: "instant-app,sonarqube"
name: sonarqube
objects:
- kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: ${SONARQUBE_ROLE}-allow-ingress
labels:
name: ${SONARQUBE_ROLE}-allow-ingress
app: sonarqube
spec:
description: |
Allow traffic from routes into the ${SONARQUBE_ROLE} container(s).
ingress:
- from:
- namespaceSelector:
matchLabels:
network.openshift.io/policy-group: ingress
podSelector:
matchLabels:
app: sonarqube
role: ${SONARQUBE_ROLE}
policyTypes:
- Ingress
- kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: ${SONARQUBE_DATABASE_ROLE}
labels:
name: ${SONARQUBE_DATABASE_ROLE}
app: sonarqube
spec:
description: |
SonarQube to talk to it's database.
ingress:
- from:
- podSelector:
matchLabels:
app: sonarqube
role: ${SONARQUBE_ROLE}
ports:
- protocol: TCP
port: 5432
podSelector:
matchLabels:
app: sonarqube
role: ${SONARQUBE_DATABASE_ROLE}
# - kind: NetworkSecurityPolicy
# apiVersion: security.devops.gov.bc.ca/v1alpha1
# metadata:
# name: sonarqube
# labels:
# name: sonarqube
# app: sonarqube
# role: ${SONARQUBE_ROLE}
# spec:
# description: |
# SonarQube to talk to it's database.
# source:
# - - app=sonarqube
# - role=${SONARQUBE_ROLE}
# destination:
# - - app=sonarqube
# - role=${SONARQUBE_DATABASE_ROLE}
- apiVersion: v1
kind: Service
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
name: sonarqube
spec:
ports:
- name: sonarqube
port: 9000
protocol: TCP
targetPort: 9000
selector:
app: sonarqube
deploymentconfig: sonarqube
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
annotations:
description: Route for SonarQube's http service.
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
name: sonarqube
spec:
port:
targetPort: sonarqube
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
to:
kind: Service
name: sonarqube
- apiVersion: v1
data:
username: YWRtaW4=
kind: Secret
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
annotations:
template.openshift.io/base64-expose-password: "{.data['password']}"
name: sonarqube-admin-password
stringData:
password: ${SONARQUBE_ADMIN_PASSWORD}
type: kubernetes.io/basic-auth
- apiVersion: v1
kind: Secret
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
annotations:
template.openshift.io/expose-password: "{.data['password']}"
name: postgresql-sonar-password
stringData:
password: ${POSTGRESQL_PASSWORD}
- apiVersion: v1
kind: ImageStream
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
name: sonarqube
spec:
tags:
- annotations:
description: The SonarQube Docker image
tags: sonarqube
from:
kind: DockerImage
name: "${SONARQUBE_SOURCE_IMAGE_NAME}:${SONARQUBE_VERSION}"
importPolicy: {}
name: "${SONARQUBE_VERSION}"
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
deploymentconfig: sonarqube
name: sonarqube
spec:
replicas: 1
selector:
app: sonarqube
deploymentconfig: sonarqube
strategy:
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
annotations:
openshift.io/container.sonarqube.image.entrypoint: '["./bin/run.sh"]'
creationTimestamp: null
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
deploymentconfig: sonarqube
spec:
containers:
- env:
- name: SONARQUBE_JDBC_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgresql-sonar-password
- name: SONARQUBE_JDBC_URL
value: "jdbc:postgresql://postgresql-sonarqube/sonar"
- name: SONARQUBE_JDBC_USERNAME
value: sonar
- name: SONAR_FORCEAUTHENTICATION
value: "true"
- name: LOG4J_FORMAT_MSG_NO_LOOKUPS
value: "true"
volumeMounts:
- mountPath: /opt/sonarqube/data
name: sonar-data
subPath: data
- mountPath: /opt/sonarqube/logs
name: sonar-logs
subPath: logs
- mountPath: /opt/sonarqube/temp
name: sonar-temp
subPath: temp
- mountPath: /opt/sonarqube/extensions/plugins
name: sonar-plugins
subPath: plugins
image: " "
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 9000
initialDelaySeconds: 60
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 5
name: sonarqube
ports:
- containerPort: 9000
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: 9000
initialDelaySeconds: 60
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 5
resources:
limits:
cpu: 1
memory: 4Gi
requests:
cpu: 500m
memory: 2Gi
terminationMessagePath: /dev/termination-log
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: sonar-data
- emptyDir: {}
name: sonar-logs
- emptyDir: {}
name: sonar-temp
- name: sonar-plugins
persistentVolumeClaim:
claimName: sonarqube-data
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- sonarqube
from:
kind: ImageStreamTag
name: "sonarqube:${SONARQUBE_VERSION}"
type: ImageChange
- apiVersion: v1
kind: Service
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_DATABASE_ROLE}
name: postgresql-sonarqube
spec:
ports:
- name: postgresql
port: 5432
protocol: TCP
targetPort: 5432
selector:
app: sonarqube
deploymentconfig: postgresql-sonarqube
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_DATABASE_ROLE}
deploymentconfig: postgresql-sonarqube
name: postgresql-sonarqube
spec:
replicas: 1
selector:
app: sonarqube
deploymentconfig: postgresql-sonarqube
strategy:
recreateParams:
timeoutSeconds: 600
resources: {}
type: Recreate
template:
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_DATABASE_ROLE}
deploymentconfig: postgresql-sonarqube
spec:
containers:
- env:
- name: POSTGRESQL_USER
value: sonar
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: postgresql-sonar-password
- name: POSTGRESQL_DATABASE
value: sonar
image: " "
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 5432
timeoutSeconds: 1
name: 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'
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 250m
memory: 256Mi
requests:
cpu: 100m
memory: 100Mi
securityContext:
capabilities: {}
privileged: false
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /var/lib/pgsql/data
name: postgresql-data
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: postgresql-data
persistentVolumeClaim:
claimName: postgresql-sonarqube-data
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- postgresql
from:
kind: ImageStreamTag
name: "postgresql:12"
namespace: openshift
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_DATABASE_ROLE}
name: postgresql-sonarqube-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: ${POSTGRESQL_PERSISTENT_VOLUME_CLASS}
resources:
requests:
storage: "${POSTGRESQL_VOLUME_CAPACITY}"
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: sonarqube
role: ${SONARQUBE_ROLE}
name: sonarqube-data
spec:
accessModes:
- ReadWriteMany
storageClassName: ${SONAR_PERSISTENT_VOLUME_CLASS}
resources:
requests:
storage: "${SONAR_VOLUME_CAPACITY}"
parameters:
- name: SONARQUBE_ROLE
displayName: SonarQube version
required: true
value: "sonarqube"
- name: SONARQUBE_DATABASE_ROLE
displayName: SonarQube version
required: true
value: "sonarqube-db"
- displayName: SonarQube Source Image Name
name: SONARQUBE_SOURCE_IMAGE_NAME
required: true
value: docker-remote.artifacts.developer.gov.bc.ca/bcgovimages/sonarqube
- displayName: SonarQube version
name: SONARQUBE_VERSION
required: true
value: "8.2.2"
- description: Password for SonarQube Server PostgreSQL backend
displayName: SonarQube's PostgreSQL Password
from: "[a-zA-Z0-9]{16}"
generate: expression
name: POSTGRESQL_PASSWORD
required: true
- description: Password for SonarQube Admin
displayName: SonarQube's Admin Password
from: "[a-zA-Z0-9]{16}"
generate: expression
name: SONARQUBE_ADMIN_PASSWORD
required: true
- description: Volume space available for PostgreSQL
displayName: PostgreSQL Volume Capacity
name: POSTGRESQL_VOLUME_CAPACITY
required: true
value: 5Gi
- description: Volume space available for SonarQube
displayName: SonarQube Volume Capacity
name: SONAR_VOLUME_CAPACITY
required: true
value: 1Gi
- name: SONAR_PERSISTENT_VOLUME_CLASS
displayName: Persistent Volume Class name
description: The class of the volume; netapp-file-standard
required: false
value: netapp-file-standard
- name: POSTGRESQL_PERSISTENT_VOLUME_CLASS
displayName: Persistent Volume Class name
description: The class of the volume; netapp-file-standard
required: false
value: netapp-file-standard