Skip to content

feat: add opencost.exporter.extraEnvFrom to source env from ConfigMap/Secret - #378

Open
ahauserv wants to merge 1 commit into
opencost:mainfrom
ahauserv:exporter-extra-env-from
Open

feat: add opencost.exporter.extraEnvFrom to source env from ConfigMap/Secret#378
ahauserv wants to merge 1 commit into
opencost:mainfrom
ahauserv:exporter-extra-env-from

Conversation

@ahauserv

@ahauserv ahauserv commented Aug 7, 2026

Copy link
Copy Markdown

opencost.exporter.extraEnv only renders literal name/value pairs, so an exporter env var whose value is not known when the values file is written cannot be supplied.

Typical case: values that are only known in the cluster at deploy time, or values that belong in a Secret rather than in chart values.

opencost:
  exporter:
    extraEnvFrom:
      - configMapRef:
          name: opencost-env
      - secretRef:
          name: opencost-env-secret

Explicit env: entries win over envFrom in Kubernetes, so everything the chart sets explicitly (including extraEnv) keeps precedence.

Chart version bumped to 2.5.30; README table row and version badge updated accordingly.

How was this tested

helm template with the values above renders on the exporter container:

envFrom:
  - configMapRef:
      name: opencost-env
  - secretRef:
      name: opencost-env-secret

With the value unset, no envFrom is rendered (unchanged output).
helm lint and helm unittest charts/opencost -f 'tests/plugins_test.yaml' pass.

The exporter container renders extraEnv as literal name/value pairs
only, so an env var whose value is not known when the values file is
written cannot be supplied. clusterIdConfigmap already works around
this for CLUSTER_ID specifically; generalise that escape hatch by
rendering an envFrom list from the new opencost.exporter.extraEnvFrom
value, letting any exporter env var come from a ConfigMap or Secret.
Value name and rendering follow the convention used by the promtail
and loki charts.

The envFrom block sits after env: to keep precedence semantics obvious;
explicit env entries win over envFrom in Kubernetes regardless of
order. Only the exporter is changed: ui.extraEnv and
sigV4Proxy.extraEnv are list-shaped and already accept valueFrom.

The README table row and version badge are updated in place; a full
helm-docs run also picks up unrelated drift from the v1.121.1 release
and is left to the publish workflow.

Signed-off-by: ahauser <andreas.hauser@vector.com>
@ahauserv
ahauserv force-pushed the exporter-extra-env-from branch from 02cafa8 to a2b63b2 Compare August 7, 2026 15:20
@ahauserv

Copy link
Copy Markdown
Author

@ameijer a small change that would make it possible to set ENVs from a secret/configmap. The workflow is waiting for an approval.

@thomasvn thomasvn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you @ahauserv!

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.

2 participants