forked from edwin/sonarqube-on-openshift-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonarqube-pgsql-db-template.yml
252 lines (250 loc) · 6.93 KB
/
sonarqube-pgsql-db-template.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
apiVersion: template.openshift.io/v1
kind: Template
labels:
template: sonarqube-pgsql-db-template
message: A Sonarqube service has been created in your project. You can access using admin/admin.
metadata:
annotations:
description: |-
Sonarqube service, with Postgresql DB.
NOTE: Data will not be gone despite restarts, preferable for production usages.
openshift.io/display-name: SonarQube (Postgresql DB)
openshift.io/documentation-url: https://docs.sonarqube.org/
openshift.io/long-description: This template deploys a SonarQube server with a standalone Postgresql DB.
tags: instant-app,sonarqube
creationTimestamp: null
name: sonarqube-pgsql-db
objects:
- apiVersion: v1
kind: Route
metadata:
annotations:
template.openshift.io/expose-uri: http://{.spec.host}{.spec.path}
name: ${SONARQUBE_SERVICE_NAME}
spec:
to:
kind: Service
name: ${SONARQUBE_SERVICE_NAME}
tls:
termination: edge
- apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
template.alpha.openshift.io/wait-for-ready: "true"
name: ${SONARQUBE_SERVICE_NAME}
spec:
replicas: 1
selector:
name: ${SONARQUBE_SERVICE_NAME}
strategy:
type: Recreate
template:
metadata:
labels:
name: ${SONARQUBE_SERVICE_NAME}
spec:
containers:
- capabilities: {}
image: 'sonarqube:latest'
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9000
protocol: TCP
livenessProbe:
failureThreshold: 30
httpGet:
path: /
port: 9000
initialDelaySeconds: 420
timeoutSeconds: 3
env:
- name: SONAR_JDBC_URL
value: jdbc:postgresql://${SONARQUBE_SERVICE_NAME}-pgsql:5432/sonar
- name: SONAR_JDBC_USERNAME
value: sonar
- name: SONAR_JDBC_PASSWORD
value: sonar
name: sonarqube
readinessProbe:
httpGet:
path: /
port: 9000
initialDelaySeconds: 3
timeoutSeconds: 3
volumeMounts:
- mountPath: /opt/sonarqube/data
name: ${SONARQUBE_SERVICE_NAME}-data
- mountPath: /opt/sonarqube/logs
name: ${SONARQUBE_SERVICE_NAME}-logs
- mountPath: /opt/sonarqube/extensions
name: ${SONARQUBE_SERVICE_NAME}-extensions
resources:
requests:
memory: ${SONARQUBE_MEMORY_LIMITS}
limits:
memory: ${SONARQUBE_MEMORY_LIMITS}
securityContext:
capabilities: {}
privileged: false
terminationMessagePath: /dev/termination-log
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: ${SONARQUBE_SERVICE_NAME}-data
persistentVolumeClaim:
claimName: ${SONARQUBE_SERVICE_NAME}-data-pv
- name: ${SONARQUBE_SERVICE_NAME}-logs
persistentVolumeClaim:
claimName: ${SONARQUBE_SERVICE_NAME}-logs-pv
- name: ${SONARQUBE_SERVICE_NAME}-extensions
persistentVolumeClaim:
claimName: ${SONARQUBE_SERVICE_NAME}-extensions-pv
triggers:
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
name: ${SONARQUBE_SERVICE_NAME}
spec:
ports:
- port: 9000
protocol: TCP
targetPort: 9000
selector:
name: ${SONARQUBE_SERVICE_NAME}
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${SONARQUBE_SERVICE_NAME}-data-pv
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${SONARQUBE_SERVICE_NAME}-logs-pv
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${SONARQUBE_SERVICE_NAME}-extensions-pv
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
# postgresql starts here
- apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
template.alpha.openshift.io/wait-for-ready: "true"
name: ${SONARQUBE_SERVICE_NAME}-pgsql
spec:
replicas: 1
selector:
name: ${SONARQUBE_SERVICE_NAME}-pgsql
strategy:
type: Recreate
template:
metadata:
labels:
name: ${SONARQUBE_SERVICE_NAME}-pgsql
spec:
containers:
- capabilities: {}
env:
- name: POSTGRESQL_USER
value: sonar
- name: POSTGRESQL_PASSWORD
value: sonar
- name: POSTGRESQL_DATABASE
value: sonar
image: 'image-registry.openshift-image-registry.svc:5000/openshift/postgresql:12'
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- /usr/libexec/check-container
- --live
initialDelaySeconds: 120
timeoutSeconds: 10
name: postgresql
ports:
- containerPort: 5432
protocol: TCP
readinessProbe:
exec:
command:
- /usr/libexec/check-container
initialDelaySeconds: 5
timeoutSeconds: 1
resources:
limits:
memory: 512Mi
securityContext:
capabilities: {}
privileged: false
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /var/lib/pgsql/data
name: ${SONARQUBE_SERVICE_NAME}-pgsql-data
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: ${SONARQUBE_SERVICE_NAME}-pgsql-data
persistentVolumeClaim:
claimName: ${SONARQUBE_SERVICE_NAME}-pgsql-data
triggers:
- type: ConfigChange
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${SONARQUBE_SERVICE_NAME}-pgsql-data
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
- apiVersion: v1
kind: Service
metadata:
annotations:
template.openshift.io/expose-uri: postgres://{.spec.clusterIP}:{.spec.ports[?(.name=="postgresql")].port}
name: ${SONARQUBE_SERVICE_NAME}-pgsql
spec:
ports:
- name: postgresql
nodePort: 0
port: 5432
protocol: TCP
targetPort: 5432
selector:
name: ${SONARQUBE_SERVICE_NAME}-pgsql
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
parameters:
- description: The name of the OpenShift Service exposed for the SonarQube container.
displayName: SonarQube Service Name
name: SONARQUBE_SERVICE_NAME
value: sonar
- description: SonarQube container memory limits.
displayName: Memory Limits
name: SONARQUBE_MEMORY_LIMITS
required: true
value: 2Gi