diff --git a/traefik/VALUES.md b/traefik/VALUES.md index 9d85cf4c7..2af47e328 100644 --- a/traefik/VALUES.md +++ b/traefik/VALUES.md @@ -60,7 +60,7 @@ Kubernetes: `>=1.22.0-0` | deployment.runtimeClassName | string | `""` | Set a runtimeClassName on pod | | deployment.shareProcessNamespace | bool | `false` | Use process namespace sharing | | deployment.terminationGracePeriodSeconds | int | `60` | Amount of time (in seconds) before Kubernetes will send the SIGKILL signal if Traefik does not shut down | -| env | list | See _values.yaml_ | Environment variables to be passed to Traefik's binary | +| env | list | See _values.yaml_ | Additional Environment variables to be passed to Traefik's binary | | envFrom | list | `[]` | Environment variables to be passed to Traefik's binary from configMaps or secrets | | experimental.kubernetesGateway.enabled | bool | `false` | Enable traefik experimental GatewayClass CRD | | experimental.plugins | object | `{}` | Enable traefik experimental plugins | diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index db223368a..c7eb8d029 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -747,6 +747,14 @@ {{- end }} {{- end }} env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace {{- if ($.Values.resources.limits).cpu }} - name: GOMAXPROCS valueFrom: diff --git a/traefik/tests/pod-config_test.yaml b/traefik/tests/pod-config_test.yaml index baa5ad774..4f6053b09 100644 --- a/traefik/tests/pod-config_test.yaml +++ b/traefik/tests/pod-config_test.yaml @@ -11,30 +11,28 @@ tests: limits: cpu: "4" asserts: - - equal: - path: spec.template.spec.containers[0].env[0].name - value: GOMAXPROCS - - equal: - path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.resource - value: limits.cpu - - equal: - path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.divisor - value: "1" + - contains: + path: spec.template.spec.containers[0].env + content: + name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: limits.cpu + divisor: "1" - it: should have set GOMEMLIMIT with cpu limit set: resources: limits: memory: "4" asserts: - - equal: - path: spec.template.spec.containers[0].env[0].name - value: GOMEMLIMIT - - equal: - path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.resource - value: limits.memory - - equal: - path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.divisor - value: "1" + - contains: + path: spec.template.spec.containers[0].env + content: + name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + divisor: "1" - it: should have not set GOMAXPROCS without cpu limit asserts: - notEqual: @@ -45,28 +43,24 @@ tests: - notEqual: path: spec.template.spec.containers[0].env[0].name value: GOMEMLIMIT - - it: should have env with specified values + - it: should have expected env + additional env with specified values set: env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - name: POD_TEST value: powpow asserts: - - equal: - path: spec.template.spec.containers[0].env[0].name - value: POD_NAME - - equal: - path: spec.template.spec.containers[0].env[0].valueFrom.fieldRef.fieldPath - value: metadata.name - - equal: - path: spec.template.spec.containers[0].env[1].name - value: POD_TEST - - equal: - path: spec.template.spec.containers[0].env[1].value - value: powpow + - contains: + path: spec.template.spec.containers[0].env + content: + name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - contains: + path: spec.template.spec.containers[0].env + content: + name: POD_TEST + value: powpow - it: should have envFrom with specified values set: envFrom: diff --git a/traefik/values.schema.json b/traefik/values.schema.json index 9d5e3c0f6..15b4079e4 100644 --- a/traefik/values.schema.json +++ b/traefik/values.schema.json @@ -142,27 +142,6 @@ "type": "object" }, "env": { - "items": { - "properties": { - "name": { - "type": "string" - }, - "valueFrom": { - "properties": { - "fieldRef": { - "properties": { - "fieldPath": { - "type": "string" - } - }, - "type": "object" - } - }, - "type": "object" - } - }, - "type": "object" - }, "type": "array" }, "envFrom": { diff --git a/traefik/values.yaml b/traefik/values.yaml index d6731c314..126db05c3 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -566,17 +566,9 @@ additionalArguments: [] # - "--providers.kubernetesingress.ingressclass=traefik-internal" # - "--log.level=DEBUG" -# -- Environment variables to be passed to Traefik's binary +# -- Additional Environment variables to be passed to Traefik's binary # @default -- See _values.yaml_ -env: -- name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name -- name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace +env: [] # -- Environment variables to be passed to Traefik's binary from configMaps or secrets envFrom: []