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
|
|
@ -101,7 +101,6 @@ let
|
|||
baoGrantWithConsumers = hiveWithController {
|
||||
deploy.bao.enable = true;
|
||||
deploy.bao.bootstrapTokenFile = "/run/secrets/bao-bootstrap.token";
|
||||
deploy.grafana.enable = true;
|
||||
deploy.swarm-otel.enable = true;
|
||||
};
|
||||
|
||||
|
|
@ -131,7 +130,6 @@ let
|
|||
# Every reader against a store it does not run, each with a leaf placed by
|
||||
# hand. The deployment in which there is no local policy unit to wait for.
|
||||
baoRemoteReaders = hiveWithController {
|
||||
deploy.grafana.enable = true;
|
||||
deploy.swarm-otel.enable = true;
|
||||
deploy.bao.clientCertFile = "/etc/pki/bao-client.pem";
|
||||
deploy.bao.clientKeyFile = "/etc/pki/bao-client-key.pem";
|
||||
|
|
@ -144,7 +142,6 @@ let
|
|||
# The readers ./glue-bao-readers-policy-order.nix orders after their policy
|
||||
# units.
|
||||
policyReaders = [
|
||||
"swarm-bao-grafana-oidc"
|
||||
"swarm-bao-otel-oidc"
|
||||
];
|
||||
|
||||
|
|
@ -706,7 +703,7 @@ let
|
|||
# run rotate a value Grafana or the metrics store already holds. The
|
||||
# controller's Grafana token is the one leaf it may replace, which it
|
||||
# does when Grafana refuses the stored token.
|
||||
name = "the Grafana reader reads its own and its forwarder's client secrets, creates its admin password, metrics bearer and datasource key, and writes the controller's Grafana token, and nothing else";
|
||||
name = "the Grafana reader reads its own client secret, creates its admin password, metrics bearer and datasource key, and writes the controller's Grafana token, and nothing else";
|
||||
ok =
|
||||
let
|
||||
s = baoGrantHere.systemd.services.swarm-bao-grafana-oidc-policy.script;
|
||||
|
|
@ -716,10 +713,6 @@ let
|
|||
path = "secret/data/swarm/services/swarm-grafana/oidc/client";
|
||||
caps = [ "read" ];
|
||||
}
|
||||
{
|
||||
path = "secret/data/swarm/services/swarm-grafana-collector/oidc/client";
|
||||
caps = [ "read" ];
|
||||
}
|
||||
{
|
||||
path = "secret/data/swarm/services/swarm-grafana/admin/password";
|
||||
caps = [
|
||||
|
|
@ -997,7 +990,7 @@ let
|
|||
lib.all (p: p != null) own
|
||||
&& !(lib.any (p: lib.elem p hiveLeaf) own)
|
||||
&& lib.length (lib.unique own) == lib.length own
|
||||
&& presents "swarm-bao-grafana-oidc" b.grafanaOidcClientCertFile b.grafanaOidcClientKeyFile
|
||||
|
||||
&& presents "swarm-bao-otel-oidc" b.otelOidcClientCertFile b.otelOidcClientKeyFile
|
||||
&& presents "swarm-bao-forwarder-oidc" b.forwarderOidcClientCertFile b.forwarderOidcClientKeyFile;
|
||||
}
|
||||
|
|
@ -1098,29 +1091,6 @@ let
|
|||
&& !(noReaders ? swarm-bao-matrix-oidc)
|
||||
&& !(noReaders ? swarm-bao-nats-callout-xkey);
|
||||
}
|
||||
{
|
||||
# The admin password and the controller's Grafana token are written under
|
||||
# Grafana's leaf, so their units wait for the unit writing that leaf's
|
||||
# role and policy; before it, the write is refused. The last arm is the
|
||||
# absence control.
|
||||
name = "grafana's admin password and controller token units are ordered after grafana's policy unit";
|
||||
ok =
|
||||
lib.all
|
||||
(
|
||||
unit:
|
||||
let
|
||||
u = baoGrantWithConsumers.systemd.services.${unit};
|
||||
in
|
||||
lib.elem "swarm-bao-grafana-oidc-policy.service" u.after
|
||||
&& lib.elem "swarm-bao-grafana-oidc-policy.service" u.wants
|
||||
&& !(lib.elem "swarm-bao-grafana-oidc-policy.service" u.requires)
|
||||
&& !(baoGrantNoReaders.systemd.services ? ${unit})
|
||||
)
|
||||
[
|
||||
"swarm-bao-grafana-admin"
|
||||
"swarm-bao-grafana-controller-token"
|
||||
];
|
||||
}
|
||||
{
|
||||
# The ordering is set apart from each reader's own definition, so it can
|
||||
# define a reader by itself: `after` on a unit nothing else declares is a
|
||||
|
|
@ -1312,9 +1282,6 @@ let
|
|||
[
|
||||
"swarm-services-cert"
|
||||
"swarm-bao-forwarder-oidc"
|
||||
"swarm-bao-grafana-admin"
|
||||
"swarm-bao-grafana-metrics-bearer"
|
||||
"swarm-bao-grafana-controller-token"
|
||||
]
|
||||
++ policyReaders
|
||||
);
|
||||
|
|
@ -2245,8 +2212,9 @@ let
|
|||
}
|
||||
{
|
||||
# Create without update: the first value stored is the one every later
|
||||
# run reads, and no run replaces it. Two leaves are the stores', the third the exporter's.
|
||||
name = "the store credential publisher's grant is create and read on the two stores' and the queue exporter's credentials and nothing else, and the PKI unit signs its leaf";
|
||||
# run reads, and no run replaces it. Three leaves are the stores' and
|
||||
# Grafana's, the fourth the exporter's.
|
||||
name = "the store credential publisher's grant is create and read on the two stores', Grafana's and the queue exporter's credentials and nothing else, and the PKI unit signs its leaf";
|
||||
ok =
|
||||
let
|
||||
s = baoGrantHere.systemd.services.swarm-bao-store-auth-policy.script;
|
||||
|
|
@ -2262,12 +2230,17 @@ let
|
|||
"create"
|
||||
"read"
|
||||
]
|
||||
&&
|
||||
(grantFor grants "secret/data/swarm/services/grafana/store-auth").caps == [
|
||||
"create"
|
||||
"read"
|
||||
]
|
||||
&&
|
||||
(grantFor grants "secret/data/swarm/services/nats/exporter-auth").caps == [
|
||||
"create"
|
||||
"read"
|
||||
]
|
||||
&& lib.length grants == 3
|
||||
&& lib.length grants == 4
|
||||
&& lib.hasInfix "auth/cert/certs/swarm-store-auth" s
|
||||
&& lib.hasInfix "allowed_common_names=swarm-store-auth" s
|
||||
&& lib.hasInfix "token_policies=swarm-store-auth" s
|
||||
|
|
@ -3217,11 +3190,6 @@ let
|
|||
machine = baoGrantWithConsumers.services.hyperhive.swarm.otel.machine;
|
||||
consumer = "opentelemetry-collector.service";
|
||||
}
|
||||
{
|
||||
fetch = "swarm-bao-grafana-oidc";
|
||||
machine = baoGrantWithConsumers.services.hyperhive.swarm.grafana.machine;
|
||||
consumer = "grafana.service";
|
||||
}
|
||||
{
|
||||
fetch = "swarm-bao-forwarder-oidc";
|
||||
machine = baoGrantWithConsumers.services.hyperhive.swarm.bao.machine;
|
||||
|
|
|
|||
Loading…
Reference in a new issue