cluster-grafana

by startxfr

Helm chartv21.3.418App 5.25.0GPL-3.0-or-laterVerified publisher

Helm chart used to configure Grafana at the cluster level, with the community grafana-operator, a Grafana instance, its route, datasources, dashboards and an optional OpenID Connect authentication (Red Hat build of Keycloak)

About this chart

Cluster Chart : Grafana

This helm chart is used to deploy Grafana managed by the community grafana-operator (Grafana Labs). It installs the operator, a Grafana instance (API grafana.integreatly.org/v1beta1) exposed by an OpenShift Route, and GrafanaDatasource and GrafanaDashboard objects.

Grafana works on its own with a local admin account. It can also authenticate its users with OpenID Connect, and read the Grafana role from the claims of the user. The provider is either a realm of the Red Hat build of Keycloak, such as the one deployed by cluster-rhbk, or any other OpenID Connect provider with explicit endpoint URLs. Secrets are rendered from the values, or sourced from an external store with the External Secrets Operator.

This chart is part of the cluster-xxx startx helm chart series that doesn't necessarily deploy pods but rather represent a cluster configuration state orchestrated by gitops tools like ArgoCD.

Requirements and guidelines

Read the startx helm-repository homepage for more information on how to use these resources.

RequirementDetail
OpenShift 4.17+ (Kubernetes 1.30+)kubeVersion of the chart, tested on OpenShift 4.22
grafana-operator 5.25community-operators catalog (provider Grafana Labs, not supported by Red Hat), package grafana-operator, channel v5. Installed by the operator sub-chart in the namespace of the instance (OwnNamespace). There is no Red Hat or certified Grafana operator. The Red Hat supported alternative for dashboards is the Cluster Observability Operator (Perses)
Grafana versionPinned with grafana.version (default 13.1.3, the default of the 5.25 operator), so an operator upgrade does not change the Grafana version
FIPSGrafana and the grafana-operator are not FIPS validated. They run on a FIPS enabled cluster, but their cryptography is not FIPS compliant
OpenID ConnectA confidential client in a Keycloak realm, such as the startx realm of cluster-rhbk with its values-startx_noinfra-grafana.yaml values, or in any other OpenID Connect provider. Grafana calls the token and userinfo endpoints from its pod, so it must trust the CA of their certificate (oidc.ca)
OpenShift OAuthWith oauthProxy.enabled, the sign in goes through the OpenShift OAuth server (federated to your identity provider) and the oauth-proxy image of the openshift ImageStream. The cookie secret Secret is expected from Vault/External Secrets or from oauthProxy.cookieSecret.value
SecretsAdmin password and client secret are expected as Argo CD Vault Plugin placeholders (<path:kv/data/...#key>), from a values file kept out of Git, or from the External Secrets Operator (externalSecret.enabled). The startx_noinfra-rhbk values file only carries a demo client secret

Deploy this helm chart on openshift

1. Connect to your Openshift cluster

oc login -t <token> <cluster-url>

2. Install the repository

helm repo add startx https://helm-repository.readthedocs.io/en/latest/repos/stable/

3. Get information about this chart

helm show chart startx/cluster-grafana

4. Install this chart

helm install cluster-grafana startx/cluster-grafana

Default values

Complete deployment of a project with the following characteristics, using the values-startx.yaml values :

  • 1 namespace: named default-grafana without constraints
  • 1 operator: named grafana-operator configured with
    • The v5 channel of the community catalog, manual install plan approval
    • The v5.25.0 version
    • Deployed under the default-grafana project (OwnNamespace OperatorGroup)
  • 1 grafana: named startx, Grafana 13.1.3, local admin account generated by the operator
  • 1 route: named startx-route (managed by the operator) with edge TLS termination and a generated host
  • 1 dashboard: named startx-welcome
# Create the project
helm install cluster-grafana-project startx/cluster-grafana -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-grafana/values-startx.yaml --set project.enabled=true
# Deploy the grafana operator
helm install cluster-grafana-operator startx/cluster-grafana -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-grafana/values-startx.yaml --set operator.enabled=true && sleep 30
# Approve the first install plan (manual approval)
oc patch installplan $(oc get installplan -n default-grafana -o jsonpath='{.items[0].metadata.name}') -n default-grafana --type merge -p '{"spec":{"approved":true}}'
# Deploy the grafana instance, its route and the startx dashboard
helm install cluster-grafana-instance startx/cluster-grafana -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-grafana/values-startx.yaml --set grafana.enabled=true,route.enabled=true,grafana_datasources.enabled=true,grafana_dashboards.enabled=true

Values files

  • startx : grafana operator and grafana instance on infra nodes, startx dashboard, and no download of the plugins preinstalled from grafana.com with plugins.preinstall_disabled, since the pod may have no internet access (see values-startx.yaml)
  • startx_noinfra : the same without the infra node placement (see values-startx_noinfra.yaml)
  • startx_noinfra-rhbk : the same, plus the OpenID Connect authentication against the startx realm of cluster-rhbk (values-startx_noinfra-grafana.yaml), the cluster trusted CA bundle and a demo client secret (see values-startx_noinfra-rhbk.yaml)
  • startx_noinfra-oauthproxy : the same without OpenID Connect, with the OpenShift oauth-proxy sidecar in front of Grafana (oauthProxy), the cookie secret read from an external store, and the data on a ReadWriteOnce volume with the Recreate strategy (see values-startx_noinfra-oauthproxy.yaml). Replace the secret store name first. It is checked with helm template only, not on a cluster.
helm install cluster-grafana startx/cluster-grafana -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-grafana/values-startx.yaml

Values dictionary

Chart level

KeyDefaultDescription
context.*default-grafana appSTARTX deployment context (labels of every object)
externalSecretDefaultsexternal-secrets.io/v1, 1h, ClusterSecretStoreDefaults for every secret sourced from an external store. secretStoreRef.name is required as soon as a secret uses externalSecret

Grafana instance (grafana)

KeyDefaultDescription
enabled, hookedfalse, falseRender the Grafana and its secrets. hooked renders the Grafana as a post-install hook
namedefaultName of the Grafana. The operator names its objects after it (<name>-deployment, <name>-service, <name>-route, <name>-admin-credentials...)
version13.1.3Grafana image tag, or full image reference with or without digest
adminSecret.enabled, name, username, passwordfalse, <name>-admin, admin, ""Admin Secret (keys username and password) read by Grafana and by the operator. When disabled, the operator generates <name>-admin-credentials (user admin, random password)
adminSecret.externalSecret.enabled, remoteRefsfalse, {}Produce the Secret with an ExternalSecret instead (keys username and password required)
specconsole logsGrafana spec merged over a base generated by the chart (see below)

The chart builds part of the Grafana spec from the other values, then merges grafana.spec over it. Keys set in grafana.spec win, and a list such as deployment.spec.template.spec.containers replaces the generated one.

Generated keyWhen
versiongrafana.version is set
route.spec (host, TLS termination)route.enabled
config.server.root_urlroute.enabled and route.host
disableDefaultAdminSecret, GF_SECURITY_ADMIN_* variablesgrafana.adminSecret.enabled
config.auth.generic_oauth, GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET variableoidc.enabled
config.auth, config.auth.proxy, oauth-proxy container, its volume and COOKIE_SECRET variable, serviceAccountName, service, reencrypt route.specoauthProxy.enabled
CA bundle volume, tls_client_caoidc.enabled and one of oidc.ca.certificate, oidc.ca.injectTrustedBundle, oidc.ca.configMap

Route (route)

KeyDefaultDescription
enabledfalseExpose Grafana with the Route managed by the operator (spec.route)
host""Host of the route (empty: generated by OpenShift). Required by oidc.enabled
termination, insecureEdgeTerminationPolicyedge, RedirectTLS termination and plain HTTP policy

OpenShift oauth-proxy sidecar (oauthProxy)

Puts the OpenShift oauth-proxy in front of Grafana. The users sign in with the OpenShift OAuth server, the proxy checks a SubjectAccessReview (--openshift-sar) and passes the user name in the X-Forwarded-User header, which Grafana trusts (auth.proxy, auto sign up). The sidecar is added to the generated Grafana spec next to the grafana container, which is not redeclared. It cannot be combined with oidc.enabled, and it requires grafana.enabled and route.enabled. The default is enabled: false and does not change the rendering.

KeyDefaultDescription
enabledfalseAdd the sidecar, the <grafana.name>-oauth-proxy ServiceAccount, the oauth-proxy Service port with a serving certificate and a reencrypt Route targeting it
image, port, upstreamimage-registry.openshift-image-registry.svc:5000/openshift/oauth-proxy:v4.4, 8443, http://localhost:3000Image, HTTPS port of the proxy and Grafana URL it forwards to
serviceAccountName, tlsSecretName<grafana.name>-oauth-proxy, <grafana.name>-oauth-tlsServiceAccount carrying the OAuth redirect reference (the route <grafana.name>-route) and Secret created by the service-ca operator
sar.namespace, sar.resource, sar.verbproject namespace, pods, getOnly the users allowed by this SubjectAccessReview can sign in. Other keys set under sar are added to it
emailDomain, args, resources*, [], {}--email-domain, additional arguments and resources of the proxy container
authProxy.disableLoginForm, authProxy.whitelisttrue, 127.0.0.1,::1Grafana auth.proxy settings. Both loopback families are needed because localhost can resolve to ::1
cookieSecret.enabled, name, valuetrue, <grafana.name>-oauth-cookie, ""Secret holding the cookie secret (key cookie_secret, 16, 24 or 32 bytes). value is required unless externalSecret is used
cookieSecret.externalSecretdisabledProduce the Secret with the External Secrets Operator (remoteRefs.cookie_secret)

The Grafana data is kept in an emptyDir unless you add a persistentVolumeClaim to grafana.spec. With a ReadWriteOnce volume, also set deployment.spec.strategy.type: Recreate in grafana.spec, otherwise the new pod fails with index is locked by another process during a rolling update. A list set in grafana.spec replaces the generated one, so a volumes override must also declare the oauth-tls volume (secret <grafana.name>-oauth-tls). The configuration comes from a Grafana deployment validated with grafana-operator 5.24 and 5.25. The templates of this chart were checked with helm template only: validate them on a cluster before relying on them.

OpenID Connect authentication (oidc)

KeyDefaultDescription
enabledfalseConfigure the Grafana generic_oauth authentication. Requires grafana.enabled, route.enabled and route.host
nameOpenID ConnectLabel of the login button
issuerUrl""Issuer of a Keycloak realm (https://<keycloak host>/realms/<realm>). The endpoints not given below are derived from it with the Keycloak layout (<issuerUrl>/protocol/openid-connect/...)
authUrl""Authorization endpoint. Required when issuerUrl is empty
tokenUrl""Token endpoint. Required when issuerUrl is empty
apiUrl""Userinfo endpoint. Required when issuerUrl is empty
signoutUrl""Logout endpoint, used as is (the chart adds no parameter). Empty with an empty issuerUrl: Grafana only logs out locally
clientId, scopesgrafana, openid email profileClient registered in the provider and requested scopes
roleAttributePathgrafanaadmin, admin, editor roles, else ViewerJMESPath expression mapping the claims of the user to a Grafana role. The default reads a top-level roles claim

Deploy cluster-grafana with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cluster-grafana on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartcluster-grafana is pinned at v21.3.418 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply