Grafana

Prerequisites

This guide assumes you have the following prerequisites in place:

Grafana

Grafana is an open-source platform for monitoring via dashboards. It can be used to visualize data from various sources.

Installation

  1. Create the following directory structure for Homepage:

    grafana/
    ├── grafana-repo.yml
    ├── grafana-release.yml
    ├── grafana-pvc.yml
    └── grafana-ingress.yml
  2. Create the grafana-repo.yml file with the following content:

    ---
    apiVersion: source.toolkit.fluxcd.io/v1
    kind: HelmRepository
    metadata:
      name: grafana-community
      namespace: flux-system
    spec:
      interval: 6h
      url: https://grafana-community.github.io/helm-charts
  3. Create the grafana-release.yml file with the following content:

    ---
    apiVersion: helm.toolkit.fluxcd.io/v2
    kind: HelmRelease
    metadata:
      name: grafana
      namespace: monitoring
    spec:
      interval: 6h
      chart:
        spec:
          chart: grafana
          version: "11.3.6"
          sourceRef:
            kind: HelmRepository
            name: grafana-community
            namespace: flux-system
          interval: 6h
      values:
        persistence:
          enabled: true
          existingClaim: grafana-longhorn
        deploymentStrategy:
          type: Recreate
  4. Create a persistent volume claim for grafana using the following content in grafana-pvc.yml:

    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: grafana-longhorn
      namespace: monitoring
    spec:
      resources:
        requests:
          storage: 2Gi
      volumeMode: Filesystem
      accessModes:
        - ReadWriteOnce
      storageClassName: longhorn
  5. Create an ingress for grafana:

    ---
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: grafana-ingress
      namespace: monitoring
      labels:
        app.kubernetes.io/name: grafana-ingress
      annotations:
        cert-manager.io/cluster-issuer: letsencrypt-cloudflare
        traefik.ingress.kubernetes.io/router.middlewares: tools-authelia@kubernetescrd
        traefik.ingress.kubernetes.io/router.entrypoints: websecure
    spec:
      ingressClassName: traefik
      tls:
      - hosts:
        - grafana.example.com
        secretName: grafana-tls
      rules:
      - host: grafana.example.com
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: grafana
                port:
                  number: 80
  6. Commit and push the files to your git repository. Flux will deploy Grafana to your cluster.