-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoperator.yaml
More file actions
768 lines (768 loc) · 20 KB
/
operator.yaml
File metadata and controls
768 lines (768 loc) · 20 KB
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
# Source: prometheus-engine/templates/priority-class.yaml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: gmp-critical
# Maximum allowed user-defined. Only system-node-critical and system-cluster-critical
# pods are higher.
value: 1000000000
description: Used for GMP collector pods.
---
# Source: prometheus-engine/templates/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: gmp-system
---
# Source: prometheus-engine/templates/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: gmp-public
---
# Source: prometheus-engine/templates/service-account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: collector
namespace: gmp-system
---
# Source: prometheus-engine/templates/service-account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: operator
namespace: gmp-system
---
# Source: prometheus-engine/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: gmp-system:collector
rules:
- resources:
- endpoints
- nodes
- nodes/metrics
- pods
- services
apiGroups: [""]
verbs: ["get", "list", "watch"]
- resources:
- configmaps
apiGroups: [""]
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
---
# Source: prometheus-engine/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: gmp-system:operator
rules:
# Resources controlled by the operator.
- resources:
- clusterpodmonitorings
- clusterrules
- globalrules
- clusternodemonitorings
- podmonitorings
- rules
apiGroups: ["monitoring.googleapis.com"]
verbs: ["get", "list", "watch"]
- resources:
- clusterpodmonitorings/status
- clusterrules/status
- globalrules/status
- clusternodemonitorings/status
- podmonitorings/status
- rules/status
apiGroups: ["monitoring.googleapis.com"]
verbs: ["get", "patch", "update"]
- resources:
- statefulsets
apiGroups: ["apps"]
verbs: ["get", "list", "watch"]
---
# Source: prometheus-engine/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: gmp-system:operator:webhook-admin
rules:
# Permission to inject CA bundles into webhook configs of fixed name.
- resources:
- validatingwebhookconfigurations
- mutatingwebhookconfigurations
apiGroups: ["admissionregistration.k8s.io"]
resourceNames:
- gmp-operator.gmp-system.monitoring.googleapis.com
verbs: ["get", "patch", "update", "watch"]
# Permission to delete legacy webhook config the operator directly created
# in previous versions.
- resources:
- validatingwebhookconfigurations
- mutatingwebhookconfigurations
apiGroups: ["admissionregistration.k8s.io"]
resourceNames:
- gmp-operator
verbs: ["delete"]
---
# Source: prometheus-engine/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: gmp-system:operator
roleRef:
name: gmp-system:operator
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
subjects:
- name: operator
namespace: gmp-system
kind: ServiceAccount
---
# Source: prometheus-engine/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: gmp-system:operator:webhook-admin
roleRef:
name: gmp-system:operator:webhook-admin
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
subjects:
- name: operator
namespace: gmp-system
kind: ServiceAccount
---
# Source: prometheus-engine/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: gmp-system:collector
roleRef:
name: gmp-system:collector
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
subjects:
- name: collector
namespace: gmp-system
kind: ServiceAccount
---
# Source: prometheus-engine/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: operator
namespace: gmp-system
rules:
- resources:
- pods
apiGroups: [""]
verbs: ["list", "watch"]
- resources:
- secrets
apiGroups: [""]
verbs: ["list", "watch", "create"]
- resources:
- secrets
apiGroups: [""]
resourceNames: ["collection", "rules", "alertmanager"]
verbs: ["get", "patch", "update"]
- resources:
- configmaps
apiGroups: [""]
verbs: ["list", "watch", "create"]
- resources:
- configmaps
apiGroups: [""]
resourceNames: ["collector", "rule-evaluator", "rules-generated"]
verbs: ["get", "patch", "update"]
- resources:
- daemonsets
apiGroups: ["apps"]
resourceNames: ["collector"]
verbs: ["get", "list", "watch", "patch", "update"]
- resources:
- deployments
apiGroups: ["apps"]
verbs: ["list", "watch"]
- resources:
- deployments
apiGroups: ["apps"]
resourceNames: ["rule-evaluator"]
verbs: ["get", "patch", "update"]
- resources:
- services
apiGroups: [""]
resourceNames: ["alertmanager"]
verbs: ["get", "list", "watch"]
- resources:
- statefulsets
apiGroups: ["apps"]
resourceNames: ["alertmanager"]
verbs: ["get", "patch", "update"]
---
# Source: prometheus-engine/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: operator
namespace: gmp-public
rules:
- resources:
- secrets
apiGroups: [""]
verbs: ["get", "list", "watch"]
- resources:
- operatorconfigs
apiGroups: ["monitoring.googleapis.com"]
verbs: ["get", "list", "watch"]
---
# Source: prometheus-engine/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: operator
namespace: gmp-public
roleRef:
name: operator
kind: Role
apiGroup: rbac.authorization.k8s.io
subjects:
- name: operator
namespace: gmp-system
kind: ServiceAccount
---
# Source: prometheus-engine/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: operator
namespace: gmp-system
roleRef:
name: operator
kind: Role
apiGroup: rbac.authorization.k8s.io
subjects:
- name: operator
kind: ServiceAccount
---
# Source: prometheus-engine/templates/alertmanager.yaml
apiVersion: v1
kind: Service
metadata:
name: alertmanager
namespace: gmp-system
spec:
selector:
app: managed-prometheus-alertmanager
app.kubernetes.io/name: alertmanager
ports:
- name: alertmanager
port: 9093
targetPort: 9093
clusterIP: None
---
# Source: prometheus-engine/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: gmp-operator
namespace: gmp-system
spec:
selector:
app.kubernetes.io/component: operator
app.kubernetes.io/name: gmp-operator
app.kubernetes.io/part-of: gmp
ports:
# This port does not do anything, but allows upgrades in the case
# of server-side apply (SSA) conflicts.
# TODO(pintohutch): remove once the SSA issues from upgrades are resolved.
- name: legacy
protocol: TCP
port: 8443
targetPort: webhook
- name: webhook
protocol: TCP
port: 443
targetPort: web
---
# Source: prometheus-engine/templates/collector.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: collector
namespace: gmp-system
spec:
selector:
matchLabels:
# DO NOT MODIFY - label selectors are immutable by the Kubernetes API.
# see: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#pod-selector.
app.kubernetes.io/name: collector
template:
metadata:
labels:
app: managed-prometheus-collector
app.kubernetes.io/name: collector
app.kubernetes.io/version: 0.11.0
annotations:
# The emptyDir for the storage and config directories prevents cluster
# autoscaling unless this annotation is set.
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
components.gke.io/component-name: managed_prometheus
spec:
serviceAccountName: collector
automountServiceAccountToken: true
priorityClassName: gmp-critical
initContainers:
- name: config-init
image: gke.gcr.io/gke-distroless/bash:20220419
command: ['/bin/bash', '-c', 'touch /prometheus/config_out/config.yaml']
volumeMounts:
- name: config-out
mountPath: /prometheus/config_out
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
containers:
- name: config-reloader
image: gke.gcr.io/prometheus-engine/config-reloader:v0.9.0-gke.1
args:
- --config-file=/prometheus/config/config.yaml
- --config-file-output=/prometheus/config_out/config.yaml
- --reload-url=http://127.0.0.1:19090/-/reload
- --ready-url=http://127.0.0.1:19090/-/ready
- --listen-address=:19091
ports:
- name: cfg-rel-metrics
containerPort: 19091
env:
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
resources:
limits:
memory: 32M
requests:
cpu: 1m
memory: 4M
volumeMounts:
- name: config
readOnly: true
mountPath: /prometheus/config
- name: config-out
mountPath: /prometheus/config_out
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
- name: prometheus
image: quay.io/prometheus/prometheus
args:
- --config.file=/prometheus/config_out/config.yaml
- --enable-feature=exemplar-storage
- --storage.tsdb.path=/prometheus/data
- --storage.tsdb.no-lockfile
# Keep 30 minutes of data. As we are backed by an emptyDir volume, this will count towards
# the containers memory usage. We could lower it further if this becomes problematic, but
# it the window for local data is quite convenient for debugging.
- --storage.tsdb.retention.time=30m
- --storage.tsdb.wal-compression
# Effectively disable compaction and make blocks short enough so that our retention window
# can be kept in practice.
- --storage.tsdb.min-block-duration=10m
- --storage.tsdb.max-block-duration=10m
- --web.listen-address=:19090
- --web.enable-lifecycle
- --web.route-prefix=/
# JSON log format is needed for GKE to display log levels correctly.
- --log.format=json
ports:
- name: prom-metrics
containerPort: 19090
# The environment variable EXTRA_ARGS will be populated by the operator.
# DO NOT specify it here.
env:
- name: GOGC
value: "25"
resources:
limits:
memory: 2G
requests:
cpu: 4m
memory: 32M
volumeMounts:
- name: storage
mountPath: /prometheus/data
- name: config-out
readOnly: true
mountPath: /prometheus/config_out
- name: collection-secret
readOnly: true
mountPath: /etc/secrets
livenessProbe:
httpGet:
port: 19090
path: /-/healthy
scheme: HTTP
readinessProbe:
httpGet:
port: 19090
path: /-/ready
scheme: HTTP
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
volumes:
- name: storage
emptyDir: {}
- name: config
configMap:
name: collector
- name: config-out
emptyDir: {}
- name: collection-secret
secret:
secretName: collection
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- arm64
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
tolerations:
- effect: NoExecute
operator: Exists
- effect: NoSchedule
operator: Exists
securityContext:
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
---
# Source: prometheus-engine/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: gmp-operator
namespace: gmp-system
labels:
app: managed-prometheus-operator
app.kubernetes.io/component: operator
app.kubernetes.io/name: gmp-operator
app.kubernetes.io/part-of: gmp
spec:
replicas: 1
selector:
matchLabels:
# DO NOT MODIFY - label selectors are immutable by the Kubernetes API.
# see: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#label-selector-updates.
app.kubernetes.io/component: operator
app.kubernetes.io/name: gmp-operator
app.kubernetes.io/part-of: gmp
template:
metadata:
labels:
app: managed-prometheus-operator
app.kubernetes.io/component: operator
app.kubernetes.io/name: gmp-operator
app.kubernetes.io/part-of: gmp
app.kubernetes.io/version: 0.11.0
spec:
serviceAccountName: operator
automountServiceAccountToken: true
priorityClassName: gmp-critical
containers:
- name: operator
image: docker.io/operatorkc24demo/gmp-operator:latest
args:
- "--project-id=kubecon2024"
- "--cluster=kind-kubecon2024-prometheus"
- "--operator-namespace=gmp-system"
- "--public-namespace=gmp-public"
- "--webhook-addr=:10250"
ports:
- name: web
# Note this should match the --listen-addr flag passed in to the operator args.
# Default is 10250.
containerPort: 10250
- name: metrics
# Note this should match the --metrics-addr flag passed in to the operator args.
# Default is 18080.
containerPort: 18080
resources:
limits:
memory: 2G
requests:
cpu: 1m
memory: 16M
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- arm64
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
tolerations:
- value: "amd64"
effect: "NoSchedule"
key: "kubernetes.io/arch"
operator: "Equal"
- value: "arm64"
effect: "NoSchedule"
key: "kubernetes.io/arch"
operator: "Equal"
securityContext:
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
---
# Source: prometheus-engine/templates/mutatingwebhookconfiguration.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: gmp-operator.gmp-system.monitoring.googleapis.com
webhooks:
- name: default.podmonitorings.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /default/monitoring.googleapis.com/v1/podmonitorings
failurePolicy: Fail
rules:
- resources:
- podmonitorings
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: default.clusterpodmonitorings.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /default/monitoring.googleapis.com/v1/clusterpodmonitorings
failurePolicy: Fail
rules:
- resources:
- clusterpodmonitorings
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
---
# Source: prometheus-engine/templates/validatingwebhookconfiguration.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: gmp-operator.gmp-system.monitoring.googleapis.com
webhooks:
- name: validate.podmonitorings.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/podmonitorings
failurePolicy: Fail
rules:
- resources:
- podmonitorings
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.clusterpodmonitorings.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/clusterpodmonitorings
failurePolicy: Fail
rules:
- resources:
- clusterpodmonitorings
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.clusternodemonitorings.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/clusternodemonitorings
failurePolicy: Fail
rules:
- resources:
- clusternodemonitorings
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.rules.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/rules
failurePolicy: Fail
rules:
- resources:
- rules
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.clusterrules.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/clusterrules
failurePolicy: Fail
rules:
- resources:
- clusterrules
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.globalrules.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/globalrules
failurePolicy: Fail
rules:
- resources:
- globalrules
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None
- name: validate.operatorconfigs.gmp-operator.gmp-system.monitoring.googleapis.com
admissionReviewVersions:
- v1
clientConfig:
# caBundle populated by operator.
service:
name: gmp-operator
namespace: gmp-system
port: 443
path: /validate/monitoring.googleapis.com/v1/operatorconfigs
failurePolicy: Fail
rules:
- resources:
- operatorconfigs
apiGroups:
- monitoring.googleapis.com
apiVersions:
- v1
operations:
- CREATE
- UPDATE
sideEffects: None