backmon

by dreitier

Helm chartv5.4.1App 6.3.1Verified publisher

Monitoring of backup files in filesystems and object storages

About this chart

Helm chart: backmon - Monitoring of backup files in filesystems and object storages

Prerequisites

RequirementVersionNotes
Kubernetes1.19+Enforced by kubeVersion of the chart. The chart uses apps/v1 and, if ingress.enabled is set, networking.k8s.io/v1
Helm3.0+3.8+ to install the chart from the OCI registry
backmon imagethe chart's appVersionPulled from Docker Hub (dreitier/backmon) by default; the same images are published to GHCR (ghcr.io/dreitier/backmon). Other versions can be set with image.tag. The BackmonStatusError rule adapts to images older than 5.0.0, everything else is only tested with the appVersion
Prometheus Operator CRDsmonitoring.coreos.com/v1Only for serviceMonitor.enabled (enabled by default) and prometheusRules.enabled
Node architectureamd64 or arm64Architectures of the published images
  • Prometheus Operator: the chart creates a ServiceMonitor by default. In a cluster without the Prometheus Operator CRDs (e.g. installed by kube-prometheus-stack), the installation fails unless you set serviceMonitor.enabled=false. backmon's metrics can then be scraped from /metrics of the service by other means.
  • Access to the backups: the pod needs network access to the object storage it monitors (S3 endpoint or storage.googleapis.com), or the backup directories have to be mounted with extraVolumes and extraVolumeMounts. backmon runs as non-root user 65532; set e.g. podSecurityContext.fsGroup if that user can't read a mounted volume (or can't delete files in it, if backups are purged).
  • Credentials: an identity that is allowed to list and read the backups, and to delete them if backups are purged: S3 access keys or a Google service account key in an existing secret (extraEnvFrom, extraVolumes), or a cloud identity bound to the service account (serviceAccount.annotations, e.g. IRSA or GKE Workload Identity). Google Cloud Storage requires a backmon image with GCS support.
  • Backup definitions: each monitored disk (bucket or directory) contains a backup_definitions.yaml, see the official documentation.
  • Ingress controller: only if ingress.enabled is set. backmon's API is not protected unless http.basic_auth is configured in backmon.config.content; /metrics is never protected.

Getting started

$ helm repo add dreitier https://dreitier.github.io/helm-charts/
$ helm repo update
$ helm install backmon dreitier/backmon

The chart is also published as OCI artifact to the GitHub Container Registry. No helm repo add is needed (Helm 3.8+):

$ helm show values oci://ghcr.io/dreitier/charts/backmon
$ helm install backmon oci://ghcr.io/dreitier/charts/backmon --version <version>

To pull the backmon image from the GitHub Container Registry instead of Docker Hub, e.g. because of Docker Hub's rate limits:

$ helm install backmon dreitier/backmon --set image.repository=ghcr.io/dreitier/backmon

Configuration parameters

The following tables lists the configurable parameters of the backmon chart and their default values.

backmon's configuration file is passed as a whole in backmon.config.content. Credentials should not be part of it: use __${VAR}__ placeholders, which backmon replaces with environment variables, and provide those from an existing secret with extraEnvFrom:

backmon:
  config:
    content: |-
      port: 8000
      update_interval: 15m
      environments:
        aws-prod:
          s3:
            access_key_id: __${BACKMON_AWS_PROD_ACCESS_KEY_ID}__
            secret_access_key: __${BACKMON_AWS_PROD_SECRET_ACCESS_KEY}__
        gcs-prod:
          gcs:
            project_id: my-gcp-project
            credentials_file: /etc/backmon/gcs/key.json

# secret with the keys BACKMON_AWS_PROD_ACCESS_KEY_ID and BACKMON_AWS_PROD_SECRET_ACCESS_KEY
extraEnvFrom:
  - name: backmon-aws

# secret with the service account key for Google Cloud Storage as key.json (requires backmon with GCS support)
extraVolumes:
  - name: gcs-key
    secret:
      secretName: backmon-gcs
extraVolumeMounts:
  - name: gcs-key
    mountPath: /etc/backmon/gcs
    readOnly: true
ParameterDescriptionDefault
replicaCountNumber of replicas1
image.repositoryImage repository. The images are published to Docker Hub (dreitier/backmon) and to the GitHub Container Registry (ghcr.io/dreitier/backmon)dreitier/backmon
image.tagImage tag; defaults to the chart's appVersion if emptysee values.yaml
image.pullPolicyImage pull policyIfNotPresent
imagePullSecretsList of image pull secrets[]
nameOverrideString to partially override the fullname template (will prepend the release name)""
fullnameOverrideString to fully override the fullname template""
serviceAccount.createWhether to create a service accounttrue
serviceAccount.annotationsAnnotations of the service account, e.g. eks.amazonaws.com/role-arn (IRSA) or iam.gke.io/gcp-service-account (GKE Workload Identity){}
serviceAccount.nameName of the service account; generated from the fullname template if empty and serviceAccount.create is true""
serviceAccount.automountServiceAccountTokenMount the service account token into the pod; only applies if serviceAccount.create is truetrue
podAnnotationsAnnotations of the pod{}
podSecurityContextSecurity context of the pod. backmon runs as non-root user 65532; set e.g. fsGroup if it has to read backup files from mounted volumes{}
securityContextSecurity context of the container{}
service.typeKubernetes Service typeClusterIP
service.portHTTP port of the service80
ingress.enabledWhether to create an Ingressfalse
ingress.classNameIngress class""
ingress.annotationsAnnotations for the Ingress{}
ingress.hostsHosts and paths of the Ingress. See values.yaml for an examplechart-example.local
ingress.tlsTLS configuration of the Ingress. See values.yaml for an example[]
resourcesResource requests and limits of the container{}
nodeSelectorNode selector of the pod{}
tolerationsTolerations of the pod[]
affinityAffinity of the pod{}
backmon.config.enabledWhether to create the configuration file from backmon.config.content. Set to false to supply your own at /etc/backmon/config.yaml, e.g. with extraVolumestrue
backmon.config.contentContent of backmon's config.yaml (official docs). Stored in a secret. Keep port: 8000see values.yaml
extraEnvFromList of existing secrets (name) whose keys are injected as environment variables, e.g. for __${VAR}__ placeholders in the configuration[]
extraEnvList of environment variables to be injected into the backmon container. See values.yaml for an example[]
extraVolumesList of volumes to be added to the pod. See values.yaml for an example[]
extraVolumeMountsList of volume mounts to be added to the backmon container. See values.yaml for an example[]
reloader.enabledAnnotate the deployment with reloader.stakater.com/auto, see Reloading the configuration. Requires Stakater Reloaderfalse
serviceMonitor.enabledWhether to deploy a ServiceMonitor object to make Prometheus scrape the application metrics. Requires the corresponding CRD to be installedtrue
prometheusRules.enabledWhether to deploy PrometheusRule objects to monitor the state of backups. Requires the corresponding CRD to be installedfalse
prometheusRules.backupOverdue.enabledAlert BackupOverdue: the latest backup is older than expectedtrue
prometheusRules.backupOverdue.gracePeriodHours a backup may be overdue before BackupOverdue fires24
prometheusRules.backupCountExceeding.enabledAlert BackupCountExceeding: more backups than retention-count (plus threshold) are presenttrue
prometheusRules.backupCountExceeding.thresholdPercentageShare of retention-count the number of backups may exceed it0.25
prometheusRules.backupPurgeStalled.enabledAlert BackupPurgeStalled: the oldest backup is older than maxAgeHours, i.e. backups are not purged anymore. Only useful for files with purge: true. Alternative to BackupCountExceeding if additional backups are expected, e.g. before deploymentsfalse
prometheusRules.backupPurgeStalled.maxAgeHoursMaximum age of the oldest backup in hours; set it to retention-age plus a grace period384
prometheusRules.backupPurgeStalled.forHow long the condition has to hold before BackupPurgeStalled fires6h
prometheusRules.backupCountShort.enabledAlert BackupCountShort: fewer backups than retention-count times threshold are presenttrue
prometheusRules.backupCountShort.thresholdPercentageShare of retention-count that has to be present0.75
prometheusRules.backupMissing.enabledAlert BackupMissing: a monitored backup disappearedtrue
prometheusRules.backupSizeChanged.enabledAlert BackupSizeChanged: the size of the latest backup changed by more than the threshold within an hourtrue
prometheusRules.backupSizeChanged.thresholdPercentageAllowed relative change of the backup size0.25
prometheusRules.backupDefinitionError.enabledAlert BackmonStatusError: backmon reports an error for a disktrue

Reloading the configuration

backmon reads its configuration file and the environment variables for __${VAR}__ placeholders when it starts, so a change needs a restart of the pod:

  • backmon.config.content is part of the checksum annotation of the pod: helm upgrade with a changed configuration rolls the deployment by itself.
  • Secrets and configmaps which are not rendered by this chart (extraEnvFrom, extraEnv, extraVolumes) can change without Helm noticing, e.g. if they are managed by External Secrets or rotated by hand. Set reloader.enabled=true to let Stakater Reloader restart the pod whenever one of the secrets or configmaps referenced by it changes. Reloader has to be installed in the cluster; without it the annotation has no effect.

Outside of Kubernetes, backmon reloads its configuration file on SIGHUP.

Development

Test local chart output

$ helm template . --debug

Deploy backmon with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has backmon 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 chartbackmon is pinned at v5.4.1 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