security(monitoring): show tenants Alerta's login apart from its keys

Tenants logged in to the Alerta UI with the Grafana credentials, the
only Secret of the release they are shown. With Alerta on a password of
its own, that password moves to a Secret that holds nothing but the
login, listed for tenants next to Grafana's, so the signing key and the
API key in the alerta Secret stay hidden. The alerta Secret is now
rendered under data alone.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil committed 2026-11-27 05:40:01 +01:00
1 parent bd1bdc7a38
commit cbdb4f64a5
4 files changed
+61 -27

No files matched your search

@@ -17,6 +17,7 @@ rules:
- secrets
resourceNames:
- grafana-admin-password
- alerta-admin-password
verbs: ["get", "list", "watch"]
- apiGroups:
- ""
@@ -44,6 +44,7 @@ spec:
include:
- resourceNames:
- grafana-admin-password
- alerta-admin-password
services:
exclude: []
include:
@@ -119,18 +119,23 @@
Alerta's admin account must not share Grafana's credentials: Alerta exposes
the whole process environment through /api/management/properties to any
admin-scoped caller, so a shared password would hand Grafana's admin over
with it. Give Alerta its own password, persisted the same way.
with it. Its own login lives in a Secret apart from this one, so tenants can
be shown it (monitoring-rd lists it) without the signing key and API key.
The entrypoint resets the admin user's password to it on every start, which
also replaces the Grafana password on installations that predate this.
*/}}
{{- $adminPassword := randAlphaNum 32 }}
{{- with lookup "v1" "Secret" .Release.Namespace "alerta-admin-password" }}
{{- with index .data "password" }}
{{- $adminPassword = b64dec . }}
{{- end }}
{{- end }}
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace "alerta" }}
{{- if $existingSecret }}
{{- $apiKey = index $existingSecret.data "alerta-api-key" | b64dec }}
{{- if index $existingSecret.data "secret-key" }}
{{- $secretKey = index $existingSecret.data "secret-key" | b64dec }}
{{- end }}
{{- if index $existingSecret.data "admin-password" }}
{{- $adminPassword = index $existingSecret.data "admin-password" | b64dec }}
{{- end }}
{{- end }}
---
apiVersion: v1
@@ -143,11 +148,18 @@ type: Opaque
data:
alerta-api-key: {{ $apiKey | b64enc }}
secret-key: {{ $secretKey | b64enc }}
admin-password: {{ $adminPassword | b64enc }}
stringData:
alertad.conf: |
DEBUG = False
SECRET_KEY = {{ $secretKey | quote }}
alertad.conf: {{ printf "DEBUG = False\nSECRET_KEY = %s\n" ($secretKey | quote) | b64enc }}
---
apiVersion: v1
kind: Secret
metadata:
name: alerta-admin-password
labels:
app: alerta
type: Opaque
data:
user: {{ b64enc "admin" }}
password: {{ $adminPassword | b64enc }}
---
apiVersion: v1
kind: ConfigMap
@@ -227,12 +239,15 @@ spec:
resources: {{- toYaml .Values.alerta.resources | nindent 12 }}
env:
- name: ADMIN_USERS
value: "admin"
valueFrom:
secretKeyRef:
name: alerta-admin-password
key: user
- name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: alerta
key: admin-password
name: alerta-admin-password
key: password
- name: ADMIN_KEY
valueFrom:
secretKeyRef:
@@ -1,4 +1,4 @@
suite: alerta is given its own signing key and admin password, decoupled from Grafana
suite: alerta is given its own signing key and admin login, decoupled from Grafana
templates:
- templates/alerta/alerta.yaml
@@ -21,24 +21,33 @@ tests:
asserts:
- isKind:
of: Secret
- equal:
path: metadata.name
value: alerta
- matchRegex:
path: stringData["alertad.conf"]
pattern: 'SECRET_KEY = "[A-Za-z0-9]{64}"'
- it: persists the signing key and admin password in the alerta Secret
documentIndex: 0
asserts:
- equal:
path: metadata.name
value: alerta
- isNotNullOrEmpty:
path: data.secret-key
- isNotNullOrEmpty:
- notExists:
path: stringData
- notExists:
path: data.admin-password
- it: keeps Alerta's login in its own Secret, apart from the signing key
documentSelector:
path: metadata.name
value: alerta-admin-password
asserts:
- isKind:
of: Secret
- equal:
path: data.user
value: YWRtaW4=
- isNotNullOrEmpty:
path: data.password
- notExists:
path: data.secret-key
- notExists:
path: data.alerta-api-key
- it: mounts the server config so Alerta reads the generated key at runtime
documentSelector:
path: kind
@@ -60,7 +69,7 @@ tests:
- key: alertad.conf
path: alertad.conf
- it: gives Alerta its own admin password instead of reusing Grafana's
- it: gives Alerta its own admin login instead of reusing Grafana's
documentSelector:
path: kind
value: Deployment
@@ -71,8 +80,16 @@ tests:
name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: alerta
key: admin-password
name: alerta-admin-password
key: password
- contains:
path: spec.template.spec.containers[0].env
content:
name: ADMIN_USERS
valueFrom:
secretKeyRef:
name: alerta-admin-password
key: user
- notContains:
path: spec.template.spec.containers[0].env
content: