-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-auth-manifest.yaml
460 lines (460 loc) · 11.8 KB
/
api-auth-manifest.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
apiVersion: v1
kind: ServiceAccount
metadata:
name: cognite-api-auth
namespace: auth
labels:
team: auth
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: search-loader-api-keys-editor-auth
labels:
team: auth
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["search-loader-api-keys"]
verbs: ["update", "get", "patch" ]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create" ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: search-loader-api-keys-editor-auth
namespace: default
labels:
team: auth
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: search-loader-api-keys-editor-auth
subjects:
- kind: ServiceAccount
name: cognite-api-auth
namespace: auth
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: api-auth
namespace: auth
labels:
team: auth
annotations:
strategy.spinnaker.io/use-source-capacity: "true"
spec:
replicas: 1
selector:
matchLabels:
app: api-auth
template:
metadata:
labels:
app: api-auth
team: auth
annotations:
prometheus.io/scrape: "true"
spec:
serviceAccountName: cognite-api-auth
imagePullSecrets:
- name: registry-secret
containers:
- name: api-auth-container
image: eu.gcr.io/cognitedata/api-auth:latest
ports:
- name: api-auth
containerPort: 4567
- name: metrics
containerPort: 4568
readinessProbe:
httpGet:
path: /health/readiness
port: api-auth
initialDelaySeconds: 15
periodSeconds: 5
livenessProbe:
httpGet:
path: /health/liveness
port: api-auth
initialDelaySeconds: 60
periodSeconds: 5
lifecycle:
preStop:
exec:
command:
- sleep
- "15"
# volumeMounts:
# - name: auth-service-account-credentials
# mountPath: /secrets/auth-service-account-credentials
# readOnly: true
resources:
limits:
cpu: 4800m
memory: 6Gi
requests:
cpu: 2400m
memory: 6Gi
env:
- name: REDIRECT_URL_BASE
value: http://localhost:8080
# valueFrom:
# configMapKeyRef:
# name: auth-service-config-map
# key: external_url
# - name: ACCOUNT
# value: ${account}
- name: SERVICE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SERVICE_NAME
value: api-auth
- name: GOOGLE_CLOUD_PROJECT
value: cognite-test
# valueFrom:
# configMapKeyRef:
# name: auth-service-config-map
# key: google_cloud_project
- name: REDIS_MASTER_HOSTNAME
value: redis
# valueFrom:
# configMapKeyRef:
# name: auth-service-config-map
# key: redis_host
- name: CLOUDSQL_MYSQL_USER
value: cognite-test
# valueFrom:
# secretKeyRef:
# name: auth-service-api-mysql-username-password
# key: username
- name: CLOUDSQL_MYSQL_PASSWORD
value: cognite-test-password
# valueFrom:
# secretKeyRef:
# name: auth-service-api-mysql-username-password
# key: password
- name: CLOUDSQL_MYSQL_HOST
value: local:7654
# value: 127.0.0.1:3306
# - name: GOOGLE_APPLICATION_CREDENTIALS
# value: /secrets/auth-service-account-credentials/credentials.json
# - name: LIGHTSTEP_ACCESS_TOKEN
# valueFrom:
# secretKeyRef:
# name: lightstep-credentials
# key: production-access-token
# - name: UNLEASH_API_URL
# value: "https://unleash.cognite.ai/api"
# - name: UNLEASH_CLIENT_SECRET
# valueFrom:
# secretKeyRef:
# name: unleash-client-credentials
# key: unleash_client_secret
# - name: cloudsql-container
# image: gcr.io/cloudsql-docker/gce-proxy:1.09
# command: ["/cloud_sql_proxy", "--dir=/cloudsql",
# "-instances=$(MYSQL_HOST_ADDRESS)=tcp:3306",
# "-credential_file=/secrets/auth-service-account-credentials/credentials.json"]
# lifecycle:
# preStop:
# exec:
# command:
# - sleep
# - "15"
# env:
# - name: MYSQL_HOST_ADDRESS
# valueFrom:
# configMapKeyRef:
# name: auth-service-config-map
# key: api_mysql_connection_name
# volumeMounts:
# - name: auth-service-account-credentials
# mountPath: /secrets/auth-service-account-credentials
# readOnly: true
# - name: ssl-certs
# mountPath: /etc/ssl/certs
# - name: cloudsql
# mountPath: /cloudsql
# resources:
# limits:
# cpu: 1200m
# memory: 1.6Gi
# requests:
# cpu: 100m
# - name: nginx-ssl-termination
# image: eu.gcr.io/cognitedata/nginx-ssl-proxy:2019-06-04T1833-6f3e833
# env:
# - name: ENABLE_SSL
# value: "true"
# - name: SERVICE_PORT_ENV_NAME
# value: "4567"
# - name: SERVICE_HOST_ENV_NAME
# value: "127.0.0.1"
# ports:
# - name: http
# containerPort: 81
# - name: https
# containerPort: 443
# - name: metrics
# containerPort: 9145
# volumeMounts:
# - name: star-cognitedata-com-tls
# mountPath: /etc/secrets
# readOnly: true
# - name: api-nginx-dhparam
# mountPath: /etc/dhparam
# readOnly: true
# resources:
# limits:
# cpu: 1200m
# memory: 1.6Gi
# readinessProbe:
# exec:
# command:
# - /usr/bin/status-switch.sh
# - status
# initialDelaySeconds: 15
# periodSeconds: 3
# lifecycle:
# preStop:
# exec:
# command:
# - /usr/bin/status-switch.sh
# - disable
# volumes:
# - name: auth-service-account-credentials
# secret:
# secretName: auth-service-account-credentials
# - name: ssl-certs
# hostPath:
# path: /etc/ssl/certs
# - name: star-cognitedata-com-tls
# secret:
# secretName: star-cognitedata-com-tls
# items:
# - key: tls.key
# path: proxykey
# - key: tls.crt
# path: proxycert
# - name: api-nginx-dhparam #TODO is this present?
# configMap:
# name: nginx-dhparam
# - name: cloudsql
# emptyDir:
---
apiVersion: v1
kind: Service
metadata:
labels:
app: api-auth
team: auth
name: api-auth
namespace: auth
spec:
externalTrafficPolicy: Local
ports:
- name: https
port: 443
protocol: TCP
targetPort: 443
- name: http
port: 80
protocol: TCP
targetPort: 81
selector:
app: api-auth
type: LoadBalancer
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: api-auth-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /aauth/
service: http://api-auth.auth
timeout_ms: 30000
labels:
ambassador:
- d0:
- iam-service
- xratelimitid:
header: "X-Ratelimit-Id"
omit_if_not_present: true
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: jwks-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /.well-known/
rewrite: /.well-known/
service: http://api-auth.auth
timeout_ms: 30000
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: login-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /login/
rewrite: /login/
service: http://api-auth.auth
timeout_ms: 30000
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: logout-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /logout/
rewrite: /logout/
service: http://api-auth.auth
timeout_ms: 30000
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: iam-resources-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /api/[^/]+/projects/[^/]+/(users|serviceaccounts|groups|apikeys|securitycategories).*
prefix_regex: true
rewrite: ''
service: http://api-auth.auth
timeout_ms: 90000
labels:
ambassador:
- d0:
- iam-service
- xratelimitid:
header: "X-Ratelimit-Id"
omit_if_not_present: true
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: projects-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /api/[^/]+/projects/[^/]+/?$
rewrite: ''
prefix_regex: true
service: http://api-auth.auth
timeout_ms: 30000
labels:
ambassador:
- d0:
- iam-service
- xratelimitid:
header: "X-Ratelimit-Id"
omit_if_not_present: true
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: empty-projects-mapping
namespace: auth
labels:
team: auth
spec:
prefix: /api/[^/]+/projects/?$
rewrite: ''
prefix_regex: true
service: http://api-auth.auth
timeout_ms: 30000
labels:
ambassador:
- d0:
- iam-service
- xratelimitid:
header: "X-Ratelimit-Id"
omit_if_not_present: true
---
apiVersion: getambassador.io/v1
kind: Mapping
metadata:
name: projects-mapping-defaultgroup
namespace: auth
labels:
team: auth
spec:
prefix: /api/[^/]+/projects/[^/]+/defaultGroup/?
rewrite: ''
prefix_regex: true
service: http://api-auth.auth
timeout_ms: 30000
labels:
ambassador:
- d0:
- iam-service
- xratelimitid:
header: "X-Ratelimit-Id"
omit_if_not_present: true
---
apiVersion: getambassador.io/v1
kind: AuthService
metadata:
name: authentication
namespace: auth
labels:
team: auth
spec:
auth_service: http://api-auth.auth
path_prefix: "/auth/extauth"
proto: http
allowed_request_headers:
- "Api-Key"
- "Authorization"
- "auth-ticket"
- "access-control-allow-credentials"
- "access-control-allow-headers"
- "access-control-allow-methods"
- "access-control-max-age"
- "access-control-allow-origin"
- "access-control-expose-headers"
- "Origin"
- "X-Request-Id"
- "x-envoy-external-address"
- "x-cdp-sdk"
- "x-cdp-app"
- "x-cdp-clienttag"
allowed_authorization_headers:
- "auth-ticket"
- "X-Ratelimit-Id"
- "X-Request-Id"
- "access-control-allow-credentials"
- "access-control-allow-headers"
- "access-control-allow-methods"
- "access-control-max-age"
- "access-control-allow-origin"
- "access-control-expose-headers"
- "content-type"
allow_request_body: false
status_on_error:
code: 503
failure_mode_allow: false
retry_policy:
retry_on: "5xx"
num_retries: 3