Skip to content

Expose Pod Information to Containers Through Environment Variables  #54

@xhensiladoda

Description

@xhensiladoda

Is your feature request related to a problem? Please describe

I need to expose pod information on my custom metrics from the container.
In more specific, I need to add the following environment variable:

env:
    - name: POD_NAME
      valueFrom:
          fieldRef:
              fieldPath: metadata.name

Currently, this is not supported on the deployment.

Describe the solution you'd like

Ideally, I would like to have a key/value filed where:

  • key is the environment variable name
  • value is the fieldPath where to retrieve the pod information

Example:

envFromFieldPath:
    POD_NAME: "metadata.name"

Describe alternatives you've considered

I have considered changing myself the chart, and adding in the deployment.yaml:

        {{- range $key, $value := .Values.extraEnvFieldPath }}
          - name: {{ $key }}
            valueFrom:
              fieldRef:
                fieldPath: {{ $value }}
          {{- end }}

Then, I specify in my values.yaml:

  extraEnvFieldPath:
    POD_NAME: "metadata.name"

After I install the chart, I get on the container environment variables:

    Environment:
      POD_NAME:                 metrics-exporter-prometheus-mongodb-query-exporter-6545c56fbxgv (v1:metadata.name)

Additional context

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions