Skip to content

[consul-exporter] Support using environment variables in command args#6897

Open
javajawa wants to merge 1 commit into
prometheus-community:mainfrom
javajawa:consul-exporter-target-env
Open

[consul-exporter] Support using environment variables in command args#6897
javajawa wants to merge 1 commit into
prometheus-community:mainfrom
javajawa:consul-exporter-target-env

Conversation

@javajawa
Copy link
Copy Markdown

@javajawa javajawa commented May 6, 2026

What this PR does / why we need it

To increase the flexibility for options and arguments in the chart, this change adds a flag invokeViaShell to the values. When enabled the consul_exporter is not directly executed by kubernetes. Instead the same command is passed to /bin/sh, which will replace any environment variables.

This allows users to pull in options from secrets on the cluster; kubernetes's downwardApi systems; or other environment ephemera. The option is disabled by default.

This allows for constructs such as

invokeViaShell: true
consulServer: "${CONSUL_HOST}:8500"
extraEnv:
  - name: CONSUL_HOST
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP

Which issue this PR fixes

Special notes for your reviewer

This change goes slightly against typical helm conventions of having values for command and args which can be overridden by the user.

As we have a always present argument specified by consulServer, I felt that building up the logic for a more generic solution would overall increase the complexity/confusion for this chart.

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

To increase the flexibility for options and arguments in the chart,
this change adds a flag `invokeViaShell` to the values. When enabled
the `consul_exporter` is not directly executed by kubernetes.
Instead the same command is passed to `/bin/sh`, which will replace
any environment variables.

This allows users to pull in options from secrets on the cluster;
kubernetes's downwardApi systems; or other environment ephemera.
The option is disabled by default.

Fixes: prometheus-community#6896
Signed-off-by: Benedict Harcourt <benedict.harcourt@futurenet.com>
@javajawa javajawa requested review from gkarthiks and timm088 as code owners May 6, 2026 14:46
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.

[prometheus-consul-exporter] Allow options to use environment variables

1 participant