prometheus-blackbox-exporter

by joaquinito2051

Helm chartv12.0.0App v0.29.1

Prometheus Blackbox Exporter

About this chart

Prometheus Blackbox Exporter

Prometheus exporter for blackbox testing

Learn more: https://github.com/prometheus/blackbox_exporter

This chart creates a Blackbox-Exporter deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.8+ with Beta APIs enabled
  • Helm >= 3.0

Usage

The chart is distributed as an OCI Artifact as well as via a traditional Helm Repository.

  • OCI Artifact: oci://ghcr.io/prometheus-community/charts/prometheus-blackbox-exporter
  • Helm Repository: https://prometheus-community.github.io/helm-charts with chart prometheus-blackbox-exporter

The installation instructions use the OCI registry. Refer to the [helm repo](helm repo) command documentation for information on installing charts via the traditional repository.

Install Chart

helm install [RELEASE_NAME] oci://ghcr.io/prometheus-community/charts/prometheus-blackbox-exporter

See configuration below.

See helm install for command documentation.

Uninstall Chart

helm uninstall [RELEASE_NAME]

This removes all the Kubernetes components associated with the chart and deletes the release.

See helm uninstall for command documentation.

Upgrading Chart

helm upgrade [RELEASE_NAME] [CHART] --install

See helm upgrade for command documentation.

To 12.0.0

The default values now meet the restricted Pod Security Standard:

  • podSecurityContext defaults to runAsNonRoot: true and seccompProfile.type: RuntimeDefault. No pod-level UID is set.
  • securityContext and configReloader.securityContext also set seccompProfile.type: RuntimeDefault, so it stays in place when podSecurityContext is overridden.
  • The ServiceAccount created by the chart now sets automountServiceAccountToken to the same value as the pod (false by default).

The pod spec changes, so the pods are restarted once on upgrade.

To restore the previous behaviour, for example on clusters whose admission policy does not allow a seccomp profile to be set (such as the restricted SCC of OpenShift before 4.11), unset the new fields. Helm merges maps, so podSecurityContext: {} is not enough:

podSecurityContext: null
securityContext:
  seccompProfile: null
configReloader:
  securityContext:
    seccompProfile: null

The documented ICMP setup (securityContext.capabilities.add: ["NET_RAW"]) is unaffected by the RuntimeDefault seccomp profile. Adding NET_RAW is not allowed by the restricted or baseline Pod Security Standards, so ICMP probes with that setup need a namespace that permits it.

To 11.0.0

This version removes support for the deprecated Kubernetes API extensions/v1beta1, networking.k8s.io/v1beta1, and rbac.authorization.k8s.io/v1beta1. and associated attributes.

To 10.0.0

  • extraEnvFromSecret got replaced with extraEnvFrom
  • extraEnv handling got changed to use k8s env definitions as list of maps

To 9.0.0

This version remove pod security policy as it is deprecated.

To 8.0.0

  • The default image is set to quay.io/prometheus/blackbox-exporter instead prom/blackbox-exporter
  • image.repository is now split into image.registry and image.repository. For the old behavior, set image.registry to an empty string and only use image.repository.

To 7.0.0

This version introduces the securityContext and podSecurityContext and removes allowICMPoption.

All previous values are setup as default. In case that you want to enable previous functionality for allowICMP you need to explicit enabled with the following configuration:

securityContext:
  readOnlyRootFilesystem: true
  allowPrivilegeEscalation: false
  capabilities:
    add: ["NET_RAW"]

To 6.0.0

This version introduces the relabeling field for the ServiceMonitor. All values in the list additionalRelabeling will now appear under relabelings instead of metricRelabelings.

To 5.0.0

This version removes Helm 2 support. Also the ingress config has changed, so you have to adapt to the example in the values.yaml.

To 4.0.0

This version create the service account by default and introduce pod security policy, it can be enabled by setting pspEnabled: true.

To 2.0.0

This version removes the podDisruptionBudget.enabled parameter and changes the default value of podDisruptionBudget to {}, in order to fix Helm 3 compatibility.

In order to upgrade, please remove podDisruptionBudget.enabled from your custom values.yaml file and set the content of podDisruptionBudget, for example:

podDisruptionBudget:
  maxUnavailable: 0

To 1.0.0

This version introduce the new recommended labels.

In order to upgrade, delete the Deployment before upgrading:

kubectl delete deployment [RELEASE_NAME]-prometheus-blackbox-exporter

Note that this will cause downtime of the blackbox.

Configuration

See Customizing the Chart Before Installing. To see all configurable options with detailed comments, visit the chart's values.yaml, or run these configuration commands:

helm show values oci://ghcr.io/prometheus-community/charts/prometheus-blackbox-exporter

TLS and basic authentication

The exporter's HTTP endpoints can be protected with an exporter-toolkit web configuration through webConfiguration. The chart passes it with --web.config.file, either rendered from webConfiguration.config into a <fullname>-web-config Secret, or from an existing Secret named in webConfiguration.existingSecret.name that holds the key web-config.yaml.

For TLS, mount the certificate and key, for example from a kubernetes.io/tls Secret:

webConfiguration:
  config:
    tls_server_config:
      cert_file: /etc/blackbox-exporter/tls/tls.crt
      key_file: /etc/blackbox-exporter/tls/tls.key

extraSecretMounts:
  - name: tls
    mountPath: /etc/blackbox-exporter/tls
    secretName: blackbox-exporter-tls
    readOnly: true

For basic authentication, add bcrypt hashes (never plain passwords) to basic_auth_users:

webConfiguration:
  config:
    basic_auth_users:
      <username>: <bcrypt-hash>

How the rest of the chart adapts:

  • With TLS only, the httpGet liveness and readiness probes use scheme: HTTPS, and the config reloader calls https://127.0.0.1:<containerPort>/-/reload (it does not verify the certificate).
  • With basic_auth_users, a client_auth_type that requires a client certificate, or an existingSecret, every path including /-/healthy requires credentials. The chart does not put credentials into the pod spec, so httpGet probes are replaced by tcpSocket probes on the same port. The config reloader cannot authenticate either, so configReloader.enabled is rejected; set configAutoReload.enabled to let the exporter reload its configuration itself.
  • ServiceMonitors and PodMonitorings are not changed automatically: set scheme: https and a matching tlsConfig on serviceMonitor, serviceMonitor.selfMonitor and podMonitoring. Scraping with basic authentication is not configured by the chart.
  • Pods restart when the inline webConfiguration.config changes (the exporter only decides between HTTP and HTTPS at startup). Changes to an existing Secret are not tracked; roll the pods yourself.

ICMP probes

The exporter first tries an unprivileged ICMP ("ping") socket and only falls back to a raw socket, which needs the NET_RAW capability, when that fails. Unprivileged ICMP sockets are allowed when the group ID of the process is within the net.ipv4.ping_group_range sysctl of the pod's network namespace. That sysctl is namespaced and on the Kubernetes list of safe sysctls, so it can be set from the pod without adding any capability, keeping capabilities.drop: ["ALL"]:

podSecurityContext:
  sysctls:
    - name: net.ipv4.ping_group_range
      value: "0 2147483647"

Some container runtimes already set this range for every container, in which case ICMP probes work without any extra configuration.

Adding the NET_RAW capability instead is still needed when:

  • the pod uses hostNetwork: true, because namespaced sysctls cannot be set on such pods, or
  • an ICMP module sets dont_fragment: true, because that IP header option can only be set on a raw socket.
securityContext:
  capabilities:
    drop: ["ALL"]
    add: ["NET_RAW"]

Kubernetes does not support ambient capabilities, so a capability added for a non-root user only ends up in the bounding set, not in the effective set of the exporter process. With the chart's default runAsUser: 1000, adding NET_RAW alone is therefore usually not enough for a raw socket, which is another reason to prefer the sysctl.

See Using sysctls in a Kubernetes Cluster and the exporter's permissions documentation.

Binary protocol (TCP) modules (PostgreSQL, LDAP, etc.)

If your module configuration requires binary send payloads — for example probing PostgreSQL SSL negotiation or LDAP STARTTLS — you cannot configure them via the config: value in values.yaml.

The contents of config: are passed through toYaml in the ConfigMap template, which round-trips the values through Helm's YAML parser, which decodes !!binary tags and re-encodes them as UTF-8 strings. Any byte ≥ 0x80 is silently corrupted or dropped. The failure only manifests at probe time as a cryptic byte-mismatch error, with no warning during helm install or helm template.

Workaround: create the blackbox config as a Kubernetes Secret outside of Helm and reference it via configExistingSecretName:

configExistingSecretName: blackbox-binary-config

The Secret must contain a blackbox.yaml key:

kubectl create secret generic blackbox-binary-config \
  --from-file=blackbox.yaml=./blackbox.yaml

This bypasses the toYaml pipeline entirely and delivers the config verbatim.

Deploy prometheus-blackbox-exporter with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has prometheus-blackbox-exporter 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 chartprometheus-blackbox-exporter is pinned at v12.0.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