-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpaci-jenkins.yaml
399 lines (399 loc) · 10.9 KB
/
paci-jenkins.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
apiVersion: v1
kind: Template
labels:
app: paci-jenkins
template: paci-jenkins-template
metadata:
annotations:
description: |-
Jenkins service for PACI. This template is heavily based on the built-in
jenkins-persistent OpenShift template. It adds an S2I buildconfig to
create Jenkins images tailored for PACI usage.
iconClass: icon-jenkins
openshift.io/display-name: PACI Jenkins
openshift.io/documentation-url: https://github.com/projectatomic/projectatomic-ci-infra
openshift.io/support-url: https://github.com/projectatomic/projectatomic-ci-infra
openshift.io/provider-display-name: Project Atomic CI
tags: paci,jenkins
name: paci-jenkins
objects:
- apiVersion: v1
kind: ImageStream
metadata:
name: paci-jenkins
namespace: ${NAMESPACE}
# this is a version of the openshift/jenkins locked to stable openshift tags,
# since we're using v3.6, which didn't do this versioning
# see: https://github.com/openshift/jenkins/issues/528#issuecomment-378381468
# Once we move away from v3.6, we can drop this and change the paci-jenkins bc
# to use the openshift/jenkins:2 tag
- apiVersion: v1
kind: ImageStream
metadata:
name: jenkins
namespace: ${NAMESPACE}
spec:
tags:
- name: stable
from:
kind: DockerImage
name: openshift/jenkins-2-centos7:v3.9
- apiVersion: v1
kind: BuildConfig
metadata:
name: paci-jenkins
# Note no triggers: we don't want e.g. git pushes/config changes to restart
# Jenkins. Let's just require manual restarts here. XXX: Should investigate if
# there's an easy way to auto-redeploy during downtimes.
spec:
source:
type: Git
git:
uri: ${REPO_URL}
ref: ${REPO_REF}
contextDir: jenkins/bc/master
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
name: jenkins:stable
forcePull: true
output:
to:
kind: ImageStreamTag
name: paci-jenkins:latest
namespace: ${NAMESPACE}
successfulBuildsHistoryLimit: 2
failedBuildsHistoryLimit: 2
- apiVersion: v1
kind: ImageStream
metadata:
name: paci-jenkins-slave
namespace: ${NAMESPACE}
- apiVersion: v1
kind: BuildConfig
metadata:
name: paci-jenkins-slave
triggers:
- type: ImageChange
imageChange: {}
- type: ConfigChange
- type: GitHub
github:
secret: ${GITHUB_WEBHOOK_SHARED_SECRET}
spec:
source:
type: Git
git:
uri: ${REPO_URL}
ref: ${REPO_REF}
contextDir: jenkins/bc/slave
strategy:
type: Docker
output:
to:
kind: ImageStreamTag
name: paci-jenkins-slave:latest
namespace: ${NAMESPACE}
successfulBuildsHistoryLimit: 2
failedBuildsHistoryLimit: 2
- apiVersion: v1
kind: ImageStream
metadata:
name: papr
namespace: ${NAMESPACE}
- apiVersion: v1
kind: BuildConfig
metadata:
name: papr
triggers:
- type: ImageChange
imageChange: {}
- type: ConfigChange
- type: GitHub
github:
secret: ${GITHUB_WEBHOOK_SHARED_SECRET}
spec:
source:
type: Git
git:
# XXX: or migrate papr to paci/ or use as submodule?
uri: ${PAPR_REPO_URL}
ref: ${PAPR_REPO_REF}
strategy:
type: Docker
output:
to:
kind: ImageStreamTag
name: papr:latest
namespace: ${NAMESPACE}
successfulBuildsHistoryLimit: 2
failedBuildsHistoryLimit: 2
- apiVersion: v1
kind: ServiceAccount
metadata:
name: papr
- apiVersion: v1
kind: RoleBinding
metadata:
name: papr-edit
roleRef:
name: edit
subjects:
- kind: ServiceAccount
name: papr
- apiVersion: v1
kind: ConfigMap
metadata:
name: papr-config
data:
config: |
github:
auth-from-env: true
publisher:
type: s3
config:
auth-from-env: true
bucket: aos-ci
rootdir: ghprb
- apiVersion: v1
kind: Route
metadata:
annotations:
template.openshift.io/expose-uri: http://{.spec.host}{.spec.path}
name: ${JENKINS_SERVICE_NAME}
spec:
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: ${JENKINS_SERVICE_NAME}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${JENKINS_SERVICE_NAME}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${VOLUME_CAPACITY}
- apiVersion: v1
kind: Secret
metadata:
name: webhook-secret
stringData:
secret: ${GITHUB_WEBHOOK_SHARED_SECRET}
- apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
template.alpha.openshift.io/wait-for-ready: "true"
name: ${JENKINS_SERVICE_NAME}
spec:
replicas: 1
selector:
name: ${JENKINS_SERVICE_NAME}
strategy:
type: Recreate
template:
metadata:
labels:
name: ${JENKINS_SERVICE_NAME}
spec:
containers:
- capabilities: {}
env:
- name: OPENSHIFT_ENABLE_OAUTH
value: ${ENABLE_OAUTH}
- name: OPENSHIFT_ENABLE_REDIRECT_PROMPT
value: "true"
- name: KUBERNETES_MASTER
value: https://kubernetes.default:443
- name: KUBERNETES_TRUST_CERTIFICATES
value: "true"
- name: JENKINS_SERVICE_NAME
value: ${JENKINS_SERVICE_NAME}
- name: JNLP_SERVICE_NAME
value: ${JNLP_SERVICE_NAME}
image: ' '
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 30
httpGet:
path: /login
port: 8080
initialDelaySeconds: 420
timeoutSeconds: 3
name: jenkins
readinessProbe:
httpGet:
path: /login
port: 8080
initialDelaySeconds: 3
timeoutSeconds: 3
resources:
limits:
memory: ${MEMORY_LIMIT}
securityContext:
capabilities: {}
privileged: false
terminationMessagePath: /dev/termination-log
volumeMounts:
- name: ${JENKINS_SERVICE_NAME}-data
mountPath: /var/lib/jenkins
- name: github-token-mount
mountPath: /etc/github-token
readOnly: true
- name: webhook-secret-mount
mountPath: /etc/webhook-secret
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
serviceAccountName: ${JENKINS_SERVICE_NAME}
volumes:
- name: ${JENKINS_SERVICE_NAME}-data
persistentVolumeClaim:
claimName: ${JENKINS_SERVICE_NAME}
- name: github-token-mount
secret:
# we expect users to have created a secret called github-token with
# the key "token" containing the actual token
secretName: github-token
- name: webhook-secret-mount
secret:
secretName: webhook-secret
triggers:
- imageChangeParams:
automatic: true
containerNames:
- jenkins
from:
kind: ImageStreamTag
name: ${JENKINS_IMAGE_STREAM_TAG}
namespace: ${NAMESPACE}
lastTriggeredImage: ""
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
serviceaccounts.openshift.io/oauth-redirectreference.jenkins: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"${JENKINS_SERVICE_NAME}"}}'
name: ${JENKINS_SERVICE_NAME}
- apiVersion: v1
kind: RoleBinding
metadata:
name: ${JENKINS_SERVICE_NAME}-edit
roleRef:
name: edit
subjects:
- kind: ServiceAccount
name: ${JENKINS_SERVICE_NAME}
- apiVersion: v1
kind: Service
metadata:
name: ${JNLP_SERVICE_NAME}
spec:
ports:
- name: agent
nodePort: 0
port: 50000
protocol: TCP
targetPort: 50000
selector:
name: ${JENKINS_SERVICE_NAME}
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.openshift.io/dependencies: '[{"name": "${JNLP_SERVICE_NAME}", "namespace": "", "kind": "Service"}]'
service.openshift.io/infrastructure: "true"
name: ${JENKINS_SERVICE_NAME}
spec:
ports:
- name: web
nodePort: 0
port: 80
protocol: TCP
targetPort: 8080
selector:
name: ${JENKINS_SERVICE_NAME}
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: BuildConfig
metadata:
name: job-builder
triggers:
- type: GitHub
github:
secret: ${GITHUB_WEBHOOK_SHARED_SECRET}
- type: ConfigChange
spec:
source:
type: Git
git:
uri: ${REPO_URL}
ref: ${REPO_REF}
strategy:
jenkinsPipelineStrategy:
jenkinsfilePath: jenkins/jjb/job-builder.Jenkinsfile
parameters:
- description: The name of the OpenShift Service exposed for the Jenkins container.
displayName: Jenkins Service Name
name: JENKINS_SERVICE_NAME
value: jenkins
- description: The name of the service used for master/slave communication.
displayName: Jenkins JNLP Service Name
name: JNLP_SERVICE_NAME
value: jenkins-jnlp
- description: Whether to enable OAuth OpenShift integration. If false, the static
account 'admin' will be initialized with the password 'password'.
displayName: Enable OAuth in Jenkins
name: ENABLE_OAUTH
value: "true"
- description: Maximum amount of memory the Jenkins container can use.
displayName: Memory Limit
name: MEMORY_LIMIT
value: 2Gi # https://github.com/openshift/jenkins/issues/501
- description: Volume space available for data, e.g. 512Mi, 2Gi.
displayName: Volume Capacity
name: VOLUME_CAPACITY
required: true
value: 1Gi
- description: Name of the ImageStreamTag to be used for the Jenkins image.
displayName: Jenkins ImageStreamTag
name: JENKINS_IMAGE_STREAM_TAG
value: paci-jenkins:latest
# Templates are not able to pick up the namespace we're currently in, so let's
# allow users to specify a different one if they didn't name the project
# "projectatomic-ci" (https://github.com/openshift/origin/issues/13934).
- description: >
The OpenShift Namespace where the Jenkins ImageStream resides. This is
usually the same namespace as the project.
displayName: Jenkins ImageStream Namespace
name: NAMESPACE
value: projectatomic-ci
required: true
- description: Git source URI for paci-jenkins, slave, and job-builder BCs
name: REPO_URL
value: https://github.com/projectatomic/projectatomic-ci-infra
- description: Git branch/tag reference
name: REPO_REF
value: master
- description: Git source URI for papr BC
name: PAPR_REPO_URL
value: https://github.com/projectatomic/papr
- description: Git branch/tag reference
name: PAPR_REPO_REF
value: master
- description: Shared webhook secret.
name: GITHUB_WEBHOOK_SHARED_SECRET
generate: expression
from: '[A-Z0-9]{32}'
required: true