fix(infra-monitoring): improve security of alertmanager-matrix bot

This commit is contained in:
WrenIX 2024-02-29 14:07:46 +01:00
parent 150153e653
commit 5e6aaaba9d
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
3 changed files with 59 additions and 6 deletions

View file

@ -41,15 +41,67 @@ spec:
{{- range $item := .rooms }} {{- range $item := .rooms }}
- {{ $item.room | quote }} - {{ $item.room | quote }}
{{- end }} {{- end }}
{{- if $.Values.alertmanager.ingress.enabled }}
alertmanager: "https://{{ $.Values.alertmanager.ingress.host | default (printf "alertmanager.%s" $.Values.commons.ingress.domain) }}" alertmanager: "https://{{ $.Values.alertmanager.ingress.host | default (printf "alertmanager.%s" $.Values.commons.ingress.domain) }}"
{{- else }}
alertmanager: "http://kube-prometheus-stack-alertmanager:9093"
{{- end }}
showLabels: true showLabels: true
{{`
template:
html: >
{{ range .Alerts }}
<font color="{{.StatusString|color}}">
{{.StatusString|icon}}
<b>{{.StatusString|upper}}</b>
</font>
<b>{{.AlertName}}</b><br/>
{{if ne .Summary "" }}
Summary: {{.Summary}}
{{end}}
{{if ne .Fingerprint ""}}
({{.Fingerprint}})
{{end}}
{{if ne .GeneratorURL ""}}
<a href="{{.GeneratorURL}}">more</a>
{{end}}
{{- $labels := dict }}
{{- range $key, $value := .Alert.Labels }}
{{- $labels = set $labels $key $value }}
{{- end }}
<br/>
{{ coalesce $labels.exported_namespace $labels.namespace "unknown" }}
{{if $.ShowLabels}}
<br/>
<b>Labels:</b>
<table>
{{ range $key := omit $labels "alertname" "severity" "exported_namespace" "namespace" |
keys | sortAlpha }}
{{ $value := get $labels $key }}
<tr>
<td>{{ $key }}</td>
<td>{{ $value }}</td>
</tr>
{{ end }}
</table>
{{end}}
<br/>
{{- end -}}
`}}
serviceAccount: serviceAccount:
create: false create: false
podSecurityContext:
fsGroup: 1000
securityContext: securityContext:
runAsUser: 65534 allowPrivilegeEscalation: false
runAsGroup: 65534 capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 1000
runAsGroup: 1000
resources: resources:
requests: requests:
@ -57,6 +109,7 @@ spec:
cpu: "100m" cpu: "100m"
limits: limits:
memory: "256Mi" memory: "256Mi"
cpu: 4
tolerations: tolerations:
{{- toYaml $.Values.commons.tolerations | nindent 6 }} {{- toYaml $.Values.commons.tolerations | nindent 6 }}

View file

@ -116,7 +116,7 @@ spec:
{{- if .Values.alertmanager.ingress.enabled }} {{- if .Values.alertmanager.ingress.enabled }}
externalUrl: "https://{{ $hostAlertmanager }}" externalUrl: "https://{{ $hostAlertmanager }}"
{{- end }} {{- end }}
replicas: 1 replicas: 2
alertmanagerConfiguration: alertmanagerConfiguration:
name: "global-alertmanager-conf" name: "global-alertmanager-conf"
alertmanagerConfigSelector: alertmanagerConfigSelector: