Grafana's read-only InfluxDB token is made automatically

The read-only token for Grafana needed a manual influx command and a
Secret. InfluxDB generates every token but the admin one and ignores a
chosen value (tested on 2.7.12), so it cannot be preset in a Secret.

Instead an init container in the Grafana pod creates it at every start
with the admin token, deletes the one from the previous start, and
writes only the read-only token to a memory-backed volume; the
provisioned datasource reads it with $__file{/run/influx/token}. The
Grafana process never sees the admin token. The grafana-influx Secret
is gone from the template and the README.

Tested in podman: InfluxDB 2.7.12, the script run twice as the Grafana
user (the old token is replaced, not piled up), and Grafana 13.2.3
reporting the datasource healthy with the file-based token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
2026-10-18 19:05:58 +02:00
co-authored by Claude Opus 5.5
parent e5549dddb0
commit 9226616261
5 changed files with 73 additions and 44 deletions
-11
View File
@@ -41,14 +41,3 @@ stringData:
# Grafana's admin login (user "admin"). Only read on first start: change it in Grafana
# afterwards, or reset it with grafana cli.
admin-password: CHANGE-ME
---
apiVersion: v1
kind: Secret
metadata:
name: grafana-influx
namespace: mg4
type: Opaque
stringData:
# A read-only InfluxDB token for the mg4 bucket, not the admin token. InfluxDB makes it;
# the command is in k8s/README.md ("Grafana's InfluxDB token").
token: CHANGE-ME-read-only-token-from-influx-auth-create