run grafana as a pod in the cluster
The Deployment swarm-grafana replaces the swarm-grafana container: one replica on a static local volume that is the container's data directory, an init container that fetches the OIDC client secret and creates the administrator password, the datasources' bearer and the encryption key in the secret store, and a sidecar that keeps the controller's Viewer token. The datasources reach the stores through the gateway with that bearer, and Grafana's /metrics asks for the stores' kind of credential, which the vhost sends. The five host units, the journal forwarder, its client glue and the unix-socket directory go with the container.
This commit is contained in:
parent
26ef09b0d7
commit
9f62e71dae
1 changed files with 1938 additions and 1953 deletions
|
|
@ -85,23 +85,20 @@ let
|
|||
# below takes a list either way and the units stay identical apart from
|
||||
# the objects they write.
|
||||
#
|
||||
# Grafana's leaf also creates its admin password (`swarm-bao-grafana-admin`
|
||||
# in ./swarm-grafana.nix) and the bearer its metrics datasource presents
|
||||
# (`swarm-bao-grafana-metrics-bearer`) and its datasource-encryption key
|
||||
# (`swarm-bao-grafana-secret-key`). `create` without `update`, so a stored
|
||||
# value is never replaced.
|
||||
# Grafana's pod logs in under this role. It creates its admin password, the
|
||||
# bearer its datasources present and its datasource-encryption key
|
||||
# (`swarm-grafana-fetch` in ./swarm-grafana.nix), `create` without `update`, so a
|
||||
# stored value is never replaced.
|
||||
#
|
||||
# The controller's Grafana token is the one it may replace:
|
||||
# `swarm-bao-grafana-controller-token` mints a new one when Grafana refuses
|
||||
# the stored one, as it does after its database is recreated.
|
||||
# The controller's Grafana token is the one it may replace: its sidecar mints a
|
||||
# new one when Grafana refuses the stored one, as it does after its database
|
||||
# is recreated.
|
||||
grafanaOidcReaders = [
|
||||
{
|
||||
name = "swarm-grafana-oidc";
|
||||
cn = baoDeploy.grafanaOidcCommonName;
|
||||
policyText =
|
||||
readStanza "${credentialMountPath}/data/swarm/services/${hyperhiveCfg.swarm.grafana.oidc.clientId}/oidc/client"
|
||||
# The journal forwarder in its container, under this same leaf.
|
||||
+ readStanza "${credentialMountPath}/data/swarm/services/${hyperhiveCfg.swarm.grafana.otel.clientId}/oidc/client"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaAdminLeaf}"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaMetricsBearerLeaf}"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaSecretKeyLeaf}"
|
||||
|
|
@ -362,11 +359,11 @@ let
|
|||
}
|
||||
];
|
||||
|
||||
# The unit that publishes the stores' listener credentials
|
||||
# The unit that publishes the stores' and Grafana's listener credentials
|
||||
# (`swarm-bao-store-auth`, ./k8s/store-credentials.nix): it creates each
|
||||
# credential when the store holds none and reads it back, `create` without
|
||||
# `update`, so a stored value is never replaced. One principal for both
|
||||
# stores and the queue's exporter, a leaf each.
|
||||
# `update`, so a stored value is never replaced. One principal for the
|
||||
# stores, Grafana and the queue's exporter, a leaf each.
|
||||
storeAuthWriters = [
|
||||
{
|
||||
name = "swarm-store-auth";
|
||||
|
|
@ -376,6 +373,7 @@ let
|
|||
[
|
||||
"victorialogs"
|
||||
"victoriametrics"
|
||||
"grafana"
|
||||
]
|
||||
+ createReadStanza "${credentialMountPath}/data/${storeAuth.exporter.leaf}";
|
||||
}
|
||||
|
|
@ -441,6 +439,9 @@ let
|
|||
# The metrics store's two responders, likewise under the ServiceAccount of
|
||||
# their pod (./k8s/render.nix, `swarm-metrics-auth`).
|
||||
++ metricsAuthReaders
|
||||
# Grafana's pod runs under the ServiceAccount of its service, `swarm-grafana`,
|
||||
# and logs in under the role its certificate has always had.
|
||||
++ map (obj: obj // { serviceAccount = grafanaPodAccount; }) grafanaOidcReaders
|
||||
++ [ { name = controllerPolicyName; } ]
|
||||
# The queue's pod holds both of its roles under one ServiceAccount: the
|
||||
# server's leaf is issued with `swarm-nats`, and the responder reads its
|
||||
|
|
@ -453,6 +454,10 @@ let
|
|||
# it: the pod is the service `swarm-nats`.
|
||||
natsPodAccount = "swarm-nats";
|
||||
|
||||
# The ServiceAccount Grafana's pod runs under: the pod is the service
|
||||
# `swarm-grafana`.
|
||||
grafanaPodAccount = "swarm-grafana";
|
||||
|
||||
# The jwt role of one principal: the token of exactly its ServiceAccount (the
|
||||
# one of its name, unless the record names another), for this store's
|
||||
# audience. Both the subject and the audience are bound, so a
|
||||
|
|
|
|||
Loading…
Reference in a new issue