-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkubernetes.yml
300 lines (294 loc) · 9.44 KB
/
kubernetes.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
# This is just sample configuration
# please replace "google-cloud-tools" with your team/organisation name
---
apiVersion: v1
kind: Namespace
metadata:
name: jenkins
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:
- kind: ServiceAccount
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
labels:
app: "google-cloud-tools-jenkins"
spec:
serviceName: "google-cloud-tools-jenkins"
replicas: 1
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
app: "google-cloud-tools-jenkins"
template:
metadata:
name: "google-cloud-tools-jenkins"
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/prometheus"
labels:
app: "google-cloud-tools-jenkins"
spec:
securityContext:
fsGroup: 1000
terminationGracePeriodSeconds: 10
serviceAccountName: "google-cloud-tools-jenkins"
nodeSelector:
cloud.google.com/gke-nodepool: "default-nodepool"
containers:
- name: jenkins
image: quay.io/google-cloud-tools/jenkins
imagePullPolicy: Always
ports:
- containerPort: 8080
name: http
- containerPort: 50000
name: slavelistener
resources:
limits:
cpu: 2
memory: 2Gi
requests:
cpu: 1
memory: 512Mi
env:
- name: JENKINS_NAME
value: "google-cloud-tools"
- name: JENKINS_URL
value: "http://google-cloud-tools-jenkins:8080"
- name: JENKINS_AGENT_URL
value: "google-cloud-tools-jenkins-agent:50000"
- name: JENKINS_HOME
value: /var/jenkins_home
- name: JENKINS_AGENT_IMAGE
value: quay.io/google-cloud-tools/jenkins-agent
- name: JENKINS_AGENT_NODE_SELECTOR
value: "default-nodepool"
- name: JENKINS_AGENT_REQUEST_CPU
value: "0.2"
- name: JENKINS_AGENT_REQUEST_MEMORY
value: "512Mi"
- name: JENKINS_AGENT_LIMIT_CPU
value: "1"
- name: JENKINS_AGENT_LIMIT_MEMORY
value: "512Mi"
- name: JENKINS_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: "google-cloud-tools-jenkins"
key: password
- name: JENKINS_ADMIN_USERNAME
valueFrom:
secretKeyRef:
name: "google-cloud-tools-jenkins"
key: username
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: LIMITS_MEMORY
valueFrom:
resourceFieldRef:
resource: limits.memory
divisor: 1Mi
- name: JAVA_OPTS
value: -Xmx$(LIMITS_MEMORY)m -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85 -Djenkins.install.runSetupWizard=false
- name: PROMETHEUS_ENDPOINT
value: prometheus
- name: PROMETHEUS_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: JENKINS_SEED_REPO
value: "[email protected]:google-cloud-tools/jenkins-setup.git"
- name: JENKINS_SEED_TARGET
value: "Seed.groovy"
- name: JENKINS_GIT_NAME
value: "google-cloud-tools"
- name: JENKINS_GIT_EMAIL
value: "[email protected]"
- name: JENKINS_GIT_CREDENTIALS_ID
value: global-scm-key-credentials
- name: JENKINS_GIT_PRIVATE_SSH_KEY_PATH
value: /etc/secrets/jenkins/ssh/private
- name: JENKINS_GIT_PUBLIC_SSH_KEY
valueFrom:
secretKeyRef:
name: "ssh-keys-google-cloud-tools-jenkins"
key: public
- name: GOOGLE_PROJECT_ID
value: google-cloud-tools
- name: SERVICE_ACCOUNT_CREDENTIALS_ID
value: google-cloud-tools-credentials
- name: SERVICE_ACCOUNT_CREDENTIALS_PATH
value: /etc/secrets/jenkins/sa/credentials.json
- name: GOOGLE_AUTH_ENABLED
value: "true"
- name: GOOGLE_AUTH_ALLOWED_DOMAIN
value: google-cloud-tools.com
- name: GOOGLE_AUTH_CLIENT_ID
valueFrom:
secretKeyRef:
name: "google-auth-credentials-google-cloud-tools-jenkins"
key: client_id
- name: GOOGLE_AUTH_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: "google-auth-credentials-google-cloud-tools-jenkins"
key: client_secret
- name: GOOGLE_ADMIN_ENABLED
value: "true"
- name: GOOGLE_ADMIN_ACCOUNT_EMAIL
value: [email protected]
- name: GOOGLE_ADMIN_CLIENT_SECRET_FILE
value: /etc/secrets/jenkins/admin/credentials.json
- name: GOOGLE_ADMIN_READ_GROUP_EMAIL
value: "[email protected]"
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
readOnly: false
- name: jenkins-jobs
mountPath: /var/jenkins_home/jobs
readOnly: false
- name: jenkins-logs
mountPath: /var/jenkins_home/logs
readOnly: false
- name: "ssh-keys-google-cloud-tools-jenkins"
readOnly: true
mountPath: "/etc/secrets/jenkins/ssh"
- name: "sa-credentials-google-cloud-tools-jenkins"
readOnly: true
mountPath: "/etc/secrets/jenkins/sa"
- name: google-admin-api-credentials
readOnly: true
mountPath: "/etc/secrets/jenkins/admin"
livenessProbe:
httpGet:
path: /login
port: 8080
initialDelaySeconds: 60
timeoutSeconds: 5
failureThreshold: 12
readinessProbe:
httpGet:
path: /login
port: 8080
initialDelaySeconds: 60
timeoutSeconds: 5
failureThreshold: 12
volumes:
- name: "ssh-keys-google-cloud-tools-jenkins"
secret:
secretName: "ssh-keys-google-cloud-tools-jenkins"
- name: "sa-credentials-google-cloud-tools-jenkins"
secret:
secretName: "sa-credentials-google-cloud-tools-jenkins"
- name: google-admin-api-credentials
secret:
secretName: google-admin-api-credentials
- name: jenkins-home
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: jenkins-jobs
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
- metadata:
name: jenkins-logs
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
spec:
selector:
app: "google-cloud-tools-jenkins"
type: ClusterIP
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: "google-cloud-tools-jenkins-agent"
namespace: "jenkins"
spec:
selector:
app: "google-cloud-tools-jenkins"
type: ClusterIP
ports:
- name: agent
port: 50000
targetPort: 50000
protocol: TCP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: "google-cloud-tools-jenkins"
namespace: "jenkins"
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/force-ssl-redirect: "true"
ingress.kubernetes.io/from-to-www-redirect: "true"
ingress.kubernetes.io/ssl-redirect: "true"
ingress.kubernetes.io/proxy-body-size: 50m
ingress.kubernetes.io/proxy-request-buffering: "off"
ingress.kubernetes.io/server-snippet: |
ignore_invalid_headers off;
ingress.kubernetes.io/configuration-snippet: |
server_tokens off;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff always;
add_header X-XSS-Protection "1; mode=block" always;
add_header 'Referrer-Policy' 'strict-origin-when-cross-origin';
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; object-src 'none'" always;
spec:
tls:
- hosts:
- "jenkins.google-cloud-tools.com"
secretName: "jenkins-tls"
rules:
- host: "jenkins.google-cloud-tools.com"
http:
paths:
- path: /
backend:
serviceName: "jenkins"
servicePort: 8080