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
3 changed files with 1938 additions and 1953 deletions
|
|
@ -168,6 +168,7 @@ let
|
|||
"swarm-controller"
|
||||
"victorialogs"
|
||||
"victoriametrics"
|
||||
"grafana"
|
||||
];
|
||||
enabledServices = lib.filter (name: deployCfg.${name}.enable) swarmServices;
|
||||
|
||||
|
|
@ -179,6 +180,7 @@ let
|
|||
ci-metrics
|
||||
victorialogs
|
||||
victoriametrics
|
||||
grafana
|
||||
;
|
||||
};
|
||||
in
|
||||
|
|
@ -320,7 +322,7 @@ in
|
|||
none of those pods.
|
||||
|
||||
- `hyperhive.darkest.space/state-<service>` for each service whose data the
|
||||
cluster keeps: `nats`, `ci-metrics`, `victorialogs` and `victoriametrics`, each when enabled. A volume's `nodeAffinity` and the pod's `nodeSelector` name it.
|
||||
cluster keeps: `nats`, `ci-metrics`, `victorialogs`, `victoriametrics` and `grafana`, each when enabled. A volume's `nodeAffinity` and the pod's `nodeSelector` name it.
|
||||
- `hyperhive.darkest.space/entry`: the node the hosts' DNS points at.
|
||||
- `svccontroller.k3s.cattle.io/enablelb`: with it on any node, the
|
||||
service load balancer binds a published port on the labelled nodes
|
||||
|
|
|
|||
|
|
@ -344,6 +344,38 @@ let
|
|||
egress = [ "store" ];
|
||||
otlp = "none";
|
||||
};
|
||||
# Grafana: the swarm's metrics UI, on a static local volume that is its
|
||||
# data directory. Its configuration, provisioning and plugins are in the
|
||||
# image; an init container fetches its secrets and a sidecar keeps the
|
||||
# controller's token (`pod`). It logs in to nothing itself and pushes no
|
||||
# telemetry. The UI and the API take Grafana's own login; its `/metrics`
|
||||
# takes the listener credential.
|
||||
swarm-grafana = {
|
||||
inherit (deployCfg.grafana) enable unit pod;
|
||||
package = deployCfg.grafana.startPackage;
|
||||
kind = "Deployment";
|
||||
healthEnv = null;
|
||||
probe = {
|
||||
path = "/api/health";
|
||||
startupFailureThreshold = 30;
|
||||
};
|
||||
etcFiles = [ ];
|
||||
publicCredentials."bao-ca.pem" = baoServerCaKey;
|
||||
listener.port = deployCfg.grafana.servicePort;
|
||||
# The secret store, and the gateway's 443: authelia's token and userinfo
|
||||
# routes and both datasources.
|
||||
egress = [
|
||||
"store"
|
||||
"identity"
|
||||
];
|
||||
baoRole = "swarm-grafana-oidc";
|
||||
localState = {
|
||||
service = "grafana";
|
||||
hostDir = deployCfg.grafana.hostDataDir;
|
||||
};
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
otlp = "none";
|
||||
};
|
||||
};
|
||||
|
||||
# Where a pod pushes telemetry. A `"hive"` service pushes to the hive
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# The listener credentials of the Victoria stores the cluster runs and of the
|
||||
# queue's exporter: the unit that creates each in the swarm secret store when it
|
||||
# The listener credentials of the Victoria stores and Grafana the cluster runs and
|
||||
# of the queue's exporter: the unit that creates each in the swarm secret store when it
|
||||
# holds none, hands it to the gateway's nginx and publishes it to the cluster as
|
||||
# the Secret the pod reads it from (the store's password, the exporter's bcrypt
|
||||
# hash). The stores' flags and the locations that send the credential are in
|
||||
# ../swarm-victorialogs.nix and ../swarm-victoriametrics.nix, the exporter's in
|
||||
# ../swarm-nats.nix; ../lib/store-auth.nix names what they share.
|
||||
# hash). The flags and the locations that send the credential are in
|
||||
# ../swarm-victorialogs.nix, ../swarm-victoriametrics.nix and ../swarm-grafana.nix,
|
||||
# the exporter's in ../swarm-nats.nix; ../lib/store-auth.nix names what they share.
|
||||
# docs/4-implementation/k8s/runtime.md has the design.
|
||||
{
|
||||
pkgs,
|
||||
|
|
@ -27,10 +27,11 @@ let
|
|||
# the files `include`d into the store locations.
|
||||
nginxGroup = config.services.nginx.group;
|
||||
|
||||
# The stores this host runs, by the name `store-auth.nix` takes.
|
||||
# The pods this host runs that take the credential, by the name `store-auth.nix` takes.
|
||||
stores =
|
||||
lib.optional deployCfg.victorialogs.enable "victorialogs"
|
||||
++ lib.optional deployCfg.victoriametrics.enable "victoriametrics";
|
||||
++ lib.optional deployCfg.victoriametrics.enable "victoriametrics"
|
||||
++ lib.optional deployCfg.grafana.enable "grafana";
|
||||
|
||||
# The queue's exporter runs in the queue's pod.
|
||||
exporterOn = deployCfg.nats.enable;
|
||||
|
|
@ -96,7 +97,7 @@ in
|
|||
];
|
||||
|
||||
systemd.services.swarm-bao-store-auth = lib.mkIf haveIdentity {
|
||||
description = "create the Victoria stores' and the queue exporter's listener credentials in the swarm secret store if absent, and publish them";
|
||||
description = "create the stores', Grafana's and the queue exporter's listener credentials in the swarm secret store if absent, and publish them";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [
|
||||
|
|
@ -216,7 +217,7 @@ in
|
|||
store_init
|
||||
store_login
|
||||
if [ "$STORE_UP" != 1 ]; then
|
||||
echo "could not log in to the swarm secret store; the stores' credentials are not published." >&2
|
||||
echo "could not log in to the swarm secret store; the listener credentials are not published." >&2
|
||||
exit 1
|
||||
fi
|
||||
${lib.concatMapStrings publish stores}
|
||||
|
|
|
|||
Loading…
Reference in a new issue