-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathrule-evaluator.yaml
More file actions
263 lines (261 loc) · 6.94 KB
/
rule-evaluator.yaml
File metadata and controls
263 lines (261 loc) · 6.94 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
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# Source: rule-evaluator/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: rule-evaluator
---
# Source: rule-evaluator/templates/configmaps.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: rule-evaluator
labels:
app.kubernetes.io/name: rule-evaluator
data:
config.yaml: |
global:
external_labels: {}
evaluation_interval: 60s
rule_files:
- "/etc/rules/*.yaml"
---
# Source: rule-evaluator/templates/configmaps.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: rules
labels:
app.kubernetes.io/name: rule-evaluator
data:
rules.yaml: |
groups:
- name: example
interval: 10s
rules:
- record: job:up:sum
expr: sum without(instance) (up)
- alert: AlwaysFiring
expr: vector(1)
---
# Source: rule-evaluator/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: rule-evaluator
rules:
- resources:
- endpoints
- nodes
- nodes/metrics
- pods
- services
apiGroups: [""]
verbs: ["get", "list", "watch"]
- resources:
- configmaps
apiGroups: [""]
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
---
# Source: rule-evaluator/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: rule-evaluator
roleRef:
name: rule-evaluator
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
subjects:
- name: rule-evaluator
namespace: default
kind: ServiceAccount
---
# Source: rule-evaluator/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: rule-evaluator
labels:
app.kubernetes.io/name: rule-evaluator
spec:
selector:
app.kubernetes.io/name: rule-evaluator
ports:
- name: rule-evaluator
port: 9092
targetPort: 9092
---
# Source: rule-evaluator/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: rule-evaluator
labels:
app.kubernetes.io/name: rule-evaluator
spec:
selector:
matchLabels:
app.kubernetes.io/name: rule-evaluator
template:
metadata:
labels:
app.kubernetes.io/name: rule-evaluator
app.kubernetes.io/version: 0.15.4
spec:
serviceAccountName: rule-evaluator
automountServiceAccountToken: true
initContainers:
- name: config-init
image: gke.gcr.io/gke-distroless/bash:gke_distroless_20250407.00_p0
command: ['/bin/bash', '-c', 'touch /prometheus/config_out/config.yaml']
volumeMounts:
- name: config-out
mountPath: /prometheus/config_out
containers:
- name: evaluator
image: gke.gcr.io/prometheus-engine/rule-evaluator:v0.15.4-gke.0
args:
- "--config.file=/prometheus/config_out/config.yaml"
- "--web.listen-address=:9092"
ports:
- name: r-eval-metrics
containerPort: 9092
resources:
limits:
memory: 1G
requests:
cpu: 1m
memory: 16M
volumeMounts:
- name: config-out
readOnly: true
mountPath: /prometheus/config_out
- name: rules-out
readOnly: true
mountPath: /etc/rules
livenessProbe:
httpGet:
port: r-eval-metrics
path: /-/healthy
readinessProbe:
httpGet:
port: r-eval-metrics
path: /-/ready
# Readiness attempts a query round-trip so we need a more generous timeout.
timeoutSeconds: 5
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
readOnlyRootFilesystem: true
- name: config-reloader
image: gke.gcr.io/prometheus-engine/config-reloader:v0.15.4-gke.0
args:
- --config-file=/prometheus/config/config.yaml
- --config-file-output=/prometheus/config_out/config.yaml
- --config-dir=/etc/rules
- --config-dir-output=/prometheus/rules_out
- --reload-url=http://127.0.0.1:9092/-/reload
- --ready-url=http://127.0.0.1:9092/-/ready
- --listen-address=:9093
ports:
- name: cfg-rel-metrics
protocol: TCP
containerPort: 9093
resources:
limits:
memory: 32M
requests:
cpu: 1m
memory: 4M
volumeMounts:
- name: config
readOnly: true
mountPath: /prometheus/config
- name: config-out
mountPath: /prometheus/config_out
- name: rules
readOnly: true
mountPath: /etc/rules
- name: rules-out
mountPath: /prometheus/rules_out
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
privileged: false
readOnlyRootFilesystem: true
volumes:
- name: config
configMap:
name: rule-evaluator
- name: config-out
emptyDir: {}
- name: rules
# Mount exactly one ConfigMap per rule type (3 total)
# - rules: namespace-scoped Rules
# - clusterrules: cluster-scoped ClusterRules
# - globalrules: GlobalRules
projected:
sources:
- configMap:
name: rules
optional: true
- configMap:
name: clusterrules
optional: true
- configMap:
name: globalrules
optional: true
- name: rules-out
emptyDir: {}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- arm64
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
tolerations:
- key: "components.gke.io/gke-managed-components"
operator: "Exists"
- 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