Stop serving Grafana as anonymous admin on the public hostname

This commit is contained in:
2026-08-17 15:17:12 +07:00
parent d1c9933b9e
commit 332cb657ee
6 changed files with 277 additions and 24 deletions
@@ -1,4 +1,16 @@
{{- if .Values.ingress.enabled }}
{{- /*
The cutover serves the new production hostname alongside the rehearsal one
from the same release, so `host` alone is not enough. `extraHosts` adds more
names against the identical path set; with none set the render is unchanged.
Note that cert-manager's ingress-shim derives Certificates from the `tls`
block, not from these rules. A host listed here but absent from `tls` is
routed over HTTP without triggering an ACME order — which is what lets a new
hostname be wired up *before* its DNS moves, without burning Let's Encrypt
failed-validation attempts on a challenge that cannot succeed yet.
*/}}
{{- $hosts := concat (list .Values.ingress.host) (default (list) .Values.ingress.extraHosts) }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
@@ -14,27 +26,29 @@ spec:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- host: {{ .Values.ingress.host | quote }}
{{- range $host := $hosts }}
- host: {{ $host | quote }}
http:
paths:
- path: /v1/rag
pathType: Prefix
backend:
service:
name: {{ include "medical-chatbot.fullname" . }}-ai-service
name: {{ include "medical-chatbot.fullname" $ }}-ai-service
port: { name: http }
{{- if .Values.observability.enabled }}
{{- if $.Values.observability.enabled }}
- path: /grafana
pathType: Prefix
backend:
service:
name: {{ include "medical-chatbot.fullname" . }}-grafana
name: {{ include "medical-chatbot.fullname" $ }}-grafana
port: { name: http }
{{- end }}
- path: /
pathType: Prefix
backend:
service:
name: {{ include "medical-chatbot.fullname" . }}-web
name: {{ include "medical-chatbot.fullname" $ }}-web
port: { name: http }
{{- end }}
{{- end }}
@@ -236,13 +236,21 @@ spec:
secretKeyRef:
name: {{ include "medical-chatbot.secretName" . }}
key: grafana-admin-password
# Anonymous access is a viewing convenience, never an admin
# bypass: this Grafana is reachable from the public internet
# through the same ingress as the app, so an anonymous Admin role
# hands strangers the datasource and dashboard APIs.
- name: GF_AUTH_ANONYMOUS_ENABLED
value: {{ .Values.observability.grafana.anonymousAdmin | quote }}
value: {{ .Values.observability.grafana.anonymous.enabled | quote }}
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
value: Admin
value: {{ .Values.observability.grafana.anonymous.role | quote }}
# Never disabled. Hiding the login form alongside anonymous Admin
# left no way to authenticate as a real user at all.
- name: GF_AUTH_DISABLE_LOGIN_FORM
value: {{ .Values.observability.grafana.anonymousAdmin | quote }}
value: "false"
{{- if .Values.ingress.enabled }}
# Must be the hostname users actually arrive on, or Grafana's own
# redirects and asset links point at the wrong site.
- name: GF_SERVER_ROOT_URL
value: "https://{{ .Values.ingress.host }}/grafana/"
- name: GF_SERVER_SERVE_FROM_SUB_PATH