Skip to content

Order of env variables in sidecontainers changed #979

Closed
@spohner

Description

@spohner

We use https://github.com/wrouesnel/postgres_exporter as a global sidecar to export metrics. In the manifest file we define environment variables based on the injected environment variables like this:

env:
- name: DATA_SOURCE_URI
  value: localhost/postgres?sslmode=disable
- name: DATA_SOURCE_USER
  value: $(POSTGRES_USER)
- name: DATA_SOURCE_PASS
  value: $(POSTGRES_PASSWORD)

With the merge of #890 the order of which environment variables are added changed. The order of the env variables is actually a part of the API spec according to kubernetes/kubernetes#40373 (could not find it in the spec docs directly).

By adding the common fields last in the env array a pattern like the one above is no longer supported and this could break some apps.

Should be an easy fix by swapping the order in the append method here

mergedEnv := append(container.Env, env...)
.

I will create a simple PR for this ASAP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions