grafana-deployment

by FZJ ICE-1

Helm chartv0.1.0MITVerified publisher

This Chart deploys and configures Grafana through an existing Grafana Operator

About this chart

Grafana Deployment Helm Chart

[!WARNING]
This Chart is deprecated and not maintained anymore.
The Monitoring Fleet Bundle has been reworked to fully use the rancher-monitoring chart, which is not using the Grafana Operator.
Thus a separate deployment for Grafana is not needed anymore.
Reason for the replacement is that the construct in this Chart, while functional, is not fully reliable when deployed (missing folder/dashboards/...).

This chart is intended to deploy and configure Grafana through an existing Grafana Operator.
An example for a full deployment using Rancher fleet can be found here.

[!note] :notebook: Note
When using Rancher, it is recommended to deploy this chart in the cattle-monitoring-system namespace together with Prometheus. and set rancherDashboardServices.enabled: true.
Through this the connections between the Monitoring section in the Rancher Dashboard and the monitoring-stack will be added automatically.
For more details check the rancher-ui-integration.yaml template.

Prerequisites

Create a namespace for the deployment:

kubectl create namespace cattle-monitoring-system

Create the following secrets in the same Namespace:

# Authentication for Grafana
kind: Secret
apiVersion: v1
type: Opaque
metadata:
  name: grafana-secrets
stringData:
  GF_SECURITY_ADMIN_USER: ...
  GF_SECURITY_ADMIN_PASSWORD: ...

Additionally a persistentVolumeClaim for Grafana (10Gi) is automatically created.

Installing the Chart

Using Helm Install via Repository

Add the repository as described here.

# Install latest Version
helm repo update
kubectl create namespace cattle-monitoring-system

helm upgrade -i -n cattle-monitoring-system <cluster-name> ict-platform/grafana-deployment -f values.yaml
# List available versions
helm search repo ict-platform --versions
# Install specific version

helm install -n cattle-monitoring-system <cluster-name> ict-platform/grafana-deployment --version <x.x.x> -f values.yaml

Using Rancher

follow the steps described here.

The grafana-deployment can be installed through the Apps -> Charts (listed in the monitoring category) Option on each cluster.

Updating the Chart

Before updating to a new version it is important to ensure that the dependant CRDs are updated beforehand.

Uninstalling the Chart and clean-up

To uninstall the Chart run:

helm uninstall -n <namespace> <deployment-name>

Afterwards there will be some CRDs and resources left which need their finalizes to be set empty to be removed:

NAMESPACE=<namespace>

# remove finalizers
for resource in $(kubectl get grafanaalertrulegroups -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafanacontactpoints -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafanadashboards -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafanadatasources -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafanafolders -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafananotificationpolicies -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

for resource in $(kubectl get grafanaserviceaccount -n $NAMESPACE -o name); do
  kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done

Known issues

Some Grafana resources (or Grafana itself) are not created but the deployment succeeds

Sometimes it can happen that while adding resources like Grafana, Dashboards, Alerts, etc. to the API works just fine, they are not actually deployed.
This usually happens, when some resources have a configuration issue.

To fix this, inspect the grafana-operator logs and check the status defined in the missing API resource.
They should have detailed information about what happened, like missing dependencies or wrong configuration.

Sometimes it can also happen that e.g. a Dashboard is created before the folder where the Dashboard should be placed in.
In that case the grafana-operator should handle the reconciling automatically, or force it by removing the affected object and redeploying it.

Deploy grafana-deployment with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has grafana-deployment 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 chartgrafana-deployment is pinned at v0.1.0 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