Skip to content

[prometheus-modbus-exporter] fix config-reloader-sidecar deployment#6875

Open
stefan-kolev wants to merge 1 commit into
prometheus-community:mainfrom
stefan-kolev:fix-modbus-exporter-config-reloader-sidecar
Open

[prometheus-modbus-exporter] fix config-reloader-sidecar deployment#6875
stefan-kolev wants to merge 1 commit into
prometheus-community:mainfrom
stefan-kolev:fix-modbus-exporter-config-reloader-sidecar

Conversation

@stefan-kolev

Copy link
Copy Markdown

Summary

The config-reloader-sidecar has never actually deployed for any chart user since it was added, due to two compounding bugs:

  1. Typo in template gate. templates/deployment.yaml:57 reads .Values.configReloaderSidecar.enable, but values.yaml provides .enabled (with a 'd'). Helm silently resolves the missing key to nil, so the sidecar block is always skipped — even with the chart's own default value of enabled: true.

  2. Missing securityContext override on the sidecar. The openenergyprojects/config-reloader-sidecar image runs as root in order to send signals to the modbus_exporter process via the shared PID namespace. The chart's default podSecurityContext.runAsNonRoot: true then causes kubelet to reject the container with:

    container has runAsNonRoot and image will run as root
    

    The chart provided no per-container securityContext override for the sidecar, so even if the typo were fixed in isolation, the sidecar would CreateContainerConfigError on default chart values.

Changes

  • templates/deployment.yaml
    • Rename .Values.configReloaderSidecar.enable.enabled to match values.yaml.
    • Add imagePullPolicy (was previously omitted).
    • Add a templated container-level securityContext block, sourced from configReloaderSidecar.securityContext.
  • values.yaml: provide a default configReloaderSidecar.securityContext with runAsNonRoot: false and runAsUser: 0, with a comment explaining why the override is necessary.
  • Chart.yaml: bump chart version 0.1.40.1.5.

The main modbus_exporter container's container-level securityContext.runAsNonRoot: true is unchanged — only the sidecar gets the explicit root override it needs.

Test plan

Verified live on a Kubernetes cluster running the chart:

  • helm lint passes.
  • helm template renders both containers, with the sidecar block correctly conditional on .enabled.
  • helm upgrade of an existing release: both modbus_exporter and config-reloader-sidecar containers come up Ready (1/1 → 2/2).
  • Editing the referenced ConfigMap and waiting now reloads modbus_exporter config without a pod rollout (which is the whole reason the sidecar exists).
  • Pre-fix behavior reproduced: with stock 0.1.4, helm template emits no sidecar at all, and explicitly setting configReloaderSidecar.enable: true (workaround) makes the sidecar appear but it then fails with CreateContainerConfigError: container has runAsNonRoot and image will run as root.

The config-reloader-sidecar has never deployed for any chart user
because of two compounding bugs:

1. templates/deployment.yaml:57 reads `.Values.configReloaderSidecar.enable`
   while values.yaml provides `.enabled` (with a 'd'). Helm silently
   resolves the missing key to nil, so the sidecar block is always
   skipped, regardless of the user's value.

2. The config-reloader-sidecar image runs as root (it sends signals to
   the modbus_exporter process via the shared PID namespace). With
   the chart's default `podSecurityContext.runAsNonRoot: true`, kubelet
   refuses to start the container with:
       "container has runAsNonRoot and image will run as root"
   The chart provided no per-container securityContext override for
   the sidecar, so even if the typo is fixed the sidecar would
   CrashLoop on the chart defaults.

Changes:

* deployment.yaml: rename `.enable` -> `.enabled` to match values.yaml,
  add `imagePullPolicy` (was missing) and a `securityContext` block
  templated from `configReloaderSidecar.securityContext`.
* values.yaml: add a default `configReloaderSidecar.securityContext`
  with `runAsNonRoot: false`, `runAsUser: 0` so the sidecar starts
  on default chart settings, with a comment explaining why.
* Chart.yaml: bump version 0.1.4 -> 0.1.5.

Verified live: with these changes, both containers come up Ready;
the modbus_exporter pod stays non-root (container-level
`securityContext.runAsNonRoot: true` is unchanged) while the sidecar
gets the explicit override it needs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stefan-kolev stefan-kolev force-pushed the fix-modbus-exporter-config-reloader-sidecar branch from 955a18c to 017bf2d Compare May 11, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant