Skip to content

Commit 45eb81a

Browse files
committed
Clean prometheus example.
Add proxy for alertmanager
1 parent c8c51ba commit 45eb81a

File tree

3 files changed

+378
-150
lines changed

3 files changed

+378
-150
lines changed

examples/prometheus/prometheus.yaml

+126-50
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ objects:
3838
annotations:
3939
serviceaccounts.openshift.io/oauth-redirectreference.prom: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"prometheus"}}'
4040
serviceaccounts.openshift.io/oauth-redirectreference.alerts: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"alerts"}}'
41+
serviceaccounts.openshift.io/oauth-redirectreference.alertmanager: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"alertmanager"}}'
4142
- apiVersion: authorization.openshift.io/v1
4243
kind: ClusterRoleBinding
4344
metadata:
@@ -87,6 +88,81 @@ objects:
8788
namespace: "${NAMESPACE}"
8889
stringData:
8990
session_secret: "${SESSION_SECRET}="
91+
92+
# Create a fully end-to-end TLS connection to the alert proxy
93+
- apiVersion: route.openshift.io/v1
94+
kind: Route
95+
metadata:
96+
name: alerts
97+
namespace: "${NAMESPACE}"
98+
spec:
99+
to:
100+
name: alerts
101+
tls:
102+
termination: Reencrypt
103+
insecureEdgeTerminationPolicy: Redirect
104+
- apiVersion: v1
105+
kind: Service
106+
metadata:
107+
annotations:
108+
service.alpha.openshift.io/serving-cert-secret-name: alerts-tls
109+
labels:
110+
name: alerts
111+
name: alerts
112+
namespace: "${NAMESPACE}"
113+
spec:
114+
ports:
115+
- name: alerts
116+
port: 443
117+
protocol: TCP
118+
targetPort: 9443
119+
selector:
120+
app: prometheus
121+
- apiVersion: v1
122+
kind: Secret
123+
metadata:
124+
name: alerts-proxy
125+
namespace: "${NAMESPACE}"
126+
stringData:
127+
session_secret: "${SESSION_SECRET}="
128+
129+
# Create a fully end-to-end TLS connection to the alertmanager proxy
130+
- apiVersion: route.openshift.io/v1
131+
kind: Route
132+
metadata:
133+
name: alertmanager
134+
namespace: "${NAMESPACE}"
135+
spec:
136+
to:
137+
name: alertmanager
138+
tls:
139+
termination: Reencrypt
140+
insecureEdgeTerminationPolicy: Redirect
141+
- apiVersion: v1
142+
kind: Service
143+
metadata:
144+
annotations:
145+
service.alpha.openshift.io/serving-cert-secret-name: alertmanager-tls
146+
labels:
147+
name: alertmanager
148+
name: alertmanager
149+
namespace: "${NAMESPACE}"
150+
spec:
151+
ports:
152+
- name: alertmanager
153+
port: 443
154+
protocol: TCP
155+
targetPort: 10443
156+
selector:
157+
app: prometheus
158+
- apiVersion: v1
159+
kind: Secret
160+
metadata:
161+
name: alertmanager-proxy
162+
namespace: "${NAMESPACE}"
163+
stringData:
164+
session_secret: "${SESSION_SECRET}="
165+
90166
- apiVersion: apps/v1beta1
91167
kind: StatefulSet
92168
metadata:
@@ -134,9 +210,9 @@ objects:
134210
- -skip-auth-regex=^/metrics
135211
volumeMounts:
136212
- mountPath: /etc/tls/private
137-
name: prometheus-tls
213+
name: prometheus-tls-secret
138214
- mountPath: /etc/proxy/secrets
139-
name: prometheus-secrets
215+
name: prometheus-proxy-secret
140216
- mountPath: /prometheus
141217
name: prometheus-data
142218

@@ -179,9 +255,9 @@ objects:
179255
- -cookie-secret-file=/etc/proxy/secrets/session_secret
180256
volumeMounts:
181257
- mountPath: /etc/tls/private
182-
name: alerts-tls
258+
name: alerts-tls-secret
183259
- mountPath: /etc/proxy/secrets
184-
name: alerts-secrets
260+
name: alerts-proxy-secrets
185261

186262
- name: alert-buffer
187263
args:
@@ -190,11 +266,39 @@ objects:
190266
imagePullPolicy: IfNotPresent
191267
volumeMounts:
192268
- mountPath: /alert-buffer
193-
name: alert-buffer-data
269+
name: alerts-data
194270
ports:
195271
- containerPort: 9099
196272
name: alert-buf
197273

274+
- name: alertmanager-proxy
275+
image: ${IMAGE_PROXY}
276+
imagePullPolicy: IfNotPresent
277+
ports:
278+
- containerPort: 10443
279+
name: web
280+
args:
281+
- -provider=openshift
282+
- -https-address=:10443
283+
- -http-address=
284+
- -email-domain=*
285+
- -upstream=http://localhost:9093
286+
- -client-id=system:serviceaccount:${NAMESPACE}:prometheus
287+
- -openshift-ca=/etc/pki/tls/cert.pem
288+
- -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
289+
- '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}'
290+
- '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}}'
291+
- -tls-cert=/etc/tls/private/tls.crt
292+
- -tls-key=/etc/tls/private/tls.key
293+
- -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
294+
- -cookie-secret-file=/etc/proxy/secrets/session_secret
295+
- -skip-auth-regex=^/metrics
296+
volumeMounts:
297+
- mountPath: /etc/tls/private
298+
name: alertmanager-tls-secret
299+
- mountPath: /etc/proxy/secrets
300+
name: alertmanager-proxy-secret
301+
198302
- name: alertmanager
199303
args:
200304
- -config.file=/etc/alertmanager/alertmanager.yml
@@ -211,31 +315,40 @@ objects:
211315

212316
restartPolicy: Always
213317
volumes:
318+
214319
- name: prometheus-config
215320
configMap:
216321
defaultMode: 420
217322
name: prometheus
218-
- name: prometheus-secrets
323+
- name: prometheus-proxy-secret
219324
secret:
220325
secretName: prometheus-proxy
221-
- name: prometheus-tls
326+
- name: prometheus-tls-secret
222327
secret:
223328
secretName: prometheus-tls
224329
- name: prometheus-data
225330
emptyDir: {}
331+
226332
- name: alertmanager-config
227333
configMap:
228334
defaultMode: 420
229-
name: prometheus-alerts
230-
- name: alerts-secrets
335+
name: alertmanager
336+
- name: alertmanager-tls-secret
337+
secret:
338+
secretName: alertmanager-tls
339+
- name: alertmanager-proxy-secret
340+
secret:
341+
secretName: alertmanager-proxy
342+
343+
- name: alerts-proxy-secrets
231344
secret:
232345
secretName: alerts-proxy
233-
- name: alerts-tls
346+
- name: alerts-tls-secret
234347
secret:
235-
secretName: prometheus-alerts-tls
348+
secretName: alerts-tls
236349
- name: alertmanager-data
237350
emptyDir: {}
238-
- name: alert-buffer-data #TODO: make persistent
351+
- name: alerts-data
239352
emptyDir: {}
240353

241354
- apiVersion: v1
@@ -438,47 +551,10 @@ objects:
438551
- targets:
439552
- "localhost:9093"
440553
441-
# Create a fully end-to-end TLS connection to the alert proxy
442-
- apiVersion: route.openshift.io/v1
443-
kind: Route
444-
metadata:
445-
name: alerts
446-
namespace: "${NAMESPACE}"
447-
spec:
448-
to:
449-
name: alerts
450-
tls:
451-
termination: Reencrypt
452-
insecureEdgeTerminationPolicy: Redirect
453-
- apiVersion: v1
454-
kind: Service
455-
metadata:
456-
annotations:
457-
service.alpha.openshift.io/serving-cert-secret-name: prometheus-alerts-tls
458-
labels:
459-
name: alerts
460-
name: alerts
461-
namespace: "${NAMESPACE}"
462-
spec:
463-
ports:
464-
- name: alerts
465-
port: 443
466-
protocol: TCP
467-
targetPort: 9443
468-
selector:
469-
app: prometheus
470-
- apiVersion: v1
471-
kind: Secret
472-
metadata:
473-
name: alerts-proxy
474-
namespace: "${NAMESPACE}"
475-
stringData:
476-
session_secret: "${SESSION_SECRET}="
477-
478554
- apiVersion: v1
479555
kind: ConfigMap
480556
metadata:
481-
name: prometheus-alerts
557+
name: alertmanager
482558
namespace: "${NAMESPACE}"
483559
data:
484560
alertmanager.yml: |

0 commit comments

Comments
 (0)