diff --git a/traefik/VALUES.md b/traefik/VALUES.md index 41e2296eb..d2a02d1d4 100644 --- a/traefik/VALUES.md +++ b/traefik/VALUES.md @@ -102,6 +102,11 @@ Kubernetes: `>=1.22.0-0` | hub.redis.username | string | `""` | The username to use when connecting to Redis endpoints. Default: "". | | hub.sendlogs | string | `nil` | | | hub.token | string | `""` | Name of `Secret` with key 'token' set to a valid license token. It enables API Gateway. | +| hub.tracing.additionalTraceHeaders | object | `{"enabled":false,"traceContext":{"parentId":"","traceId":"","traceParent":"","traceState":""}}` | Tracing headers to duplicate. To configure the following, tracing.otlp.enabled needs to be set to true. | +| hub.tracing.additionalTraceHeaders.traceContext.parentId | string | `""` | Name of the header that will contain the parent-id header copy. | +| hub.tracing.additionalTraceHeaders.traceContext.traceId | string | `""` | Name of the header that will contain the trace-id copy. | +| hub.tracing.additionalTraceHeaders.traceContext.traceParent | string | `""` | Name of the header that will contain the traceparent copy. | +| hub.tracing.additionalTraceHeaders.traceContext.traceState | string | `""` | Name of the header that will contain the tracestate copy. | | image.pullPolicy | string | `"IfNotPresent"` | Traefik image pull policy | | image.registry | string | `"docker.io"` | Traefik image host registry | | image.repository | string | `"traefik"` | Traefik image repository | diff --git a/traefik/templates/_helpers.tpl b/traefik/templates/_helpers.tpl index 718f54d8d..7a91db362 100644 --- a/traefik/templates/_helpers.tpl +++ b/traefik/templates/_helpers.tpl @@ -170,7 +170,9 @@ Key: {{ $cert.Key | b64enc }} {{- if kindIs "map" $value }} {{- include "traefik.yaml2CommandLineArgsRec" (dict "path" (printf "%s.%s" $path $key) "content" $value) -}} {{- else }} + {{- with $value }} --{{ join "." (list $path $key)}}={{ join "," $value }} + {{- end -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index 2d8515187..19bdc651c 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -812,6 +812,9 @@ {{- with .sendlogs }} - "--hub.sendlogs={{ . }}" {{- end }} + {{- if and $.Values.tracing.otlp.enabled .tracing.additionalTraceHeaders.enabled }} + {{- include "traefik.yaml2CommandLineArgs" (dict "path" "hub.tracing.additionalTraceHeaders.traceContext" "content" $.Values.hub.tracing.additionalTraceHeaders.traceContext) | nindent 10 }} + {{- end }} {{- end }} {{- end }} env: diff --git a/traefik/templates/requirements.yaml b/traefik/templates/requirements.yaml index d2b1f76e6..85bd8acb9 100644 --- a/traefik/templates/requirements.yaml +++ b/traefik/templates/requirements.yaml @@ -47,3 +47,20 @@ {{- if and (semverCompare "= v3.1.0."}} {{- end }} + + +{{- if $.Values.hub.token -}} + {{ if not $.Values.image.tag }} + {{ fail "When using Traefik Hub image tag needs to be specified !" }} + {{- end -}} + + {{ $hubVersion := (split "@" (default "v3" $.Values.image.tag))._0 | replace "latest-" "" }} + + {{- if and (semverCompare "= v3.9.0."}} + {{- end }} + + {{- if and (not $.Values.tracing.otlp.enabled) .Values.hub.tracing.additionalTraceHeaders.enabled }} + {{ fail "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled."}} + {{- end }} +{{- end }} diff --git a/traefik/tests/requirements-config_test.yaml b/traefik/tests/requirements-config_test.yaml index 5c5098ba7..bf69f51de 100644 --- a/traefik/tests/requirements-config_test.yaml +++ b/traefik/tests/requirements-config_test.yaml @@ -65,6 +65,10 @@ tests: - notFailedTemplate: {} - it: should fail when using traefik-hub API management with namespaced RBACs set: + image: + registry: "ghcr.io" + repository: "traefik/traefik-hub" + tag: "v3" hub: token: xxx apimanagement: @@ -141,3 +145,38 @@ tests: asserts: - failedTemplate: errorMessage: "ERROR: safeQueryParams is a feature only available for traefik >= v3.1.0." + - it: should fail when using Traefik Hub without image registry and repository specified. + set: + hub: + token: "xxx" + asserts: + - failedTemplate: + errorMessage: "When using Traefik Hub image tag needs to be specified !" + - it: should fail when using hub.tracing.additionalTraceHeaders on Traefik Hub < 3.9.0 + set: + image: + registry: "ghcr.io" + repository: "traefik/traefik-hub" + tag: v3.8.0 + hub: + token: "xxx" + tracing: + additionalTraceHeaders: + enabled: true + asserts: + - failedTemplate: + errorMessage: "ERROR: additionalTraceHeaders is a feature only available for traefik-hub >= v3.9.0." + - it: should fail when using hub.tracing.additionalTraceHeaders without tracing.otlp enabled + set: + image: + registry: "ghcr.io" + repository: "traefik/traefik-hub" + tag: v3.9.0 + hub: + token: "xxx" + tracing: + additionalTraceHeaders: + enabled: true + asserts: + - failedTemplate: + errorMessage: "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled." diff --git a/traefik/tests/traefik-config_test.yaml b/traefik/tests/traefik-config_test.yaml index a4ef8e8af..3660da8e4 100644 --- a/traefik/tests/traefik-config_test.yaml +++ b/traefik/tests/traefik-config_test.yaml @@ -780,3 +780,35 @@ tests: asserts: - failedTemplate: errorMessage: "ERROR: allowACMEByPass has been introduced with Traefik v3.1.3+" + - it: should be possible to configure Traefik Hub additionalTraceHeaders + set: + image: + registry: "ghcr.io" + repository: "traefik/traefik-hub" + tag: v3.9.0 + tracing: + otlp: + enabled: true + hub: + token: "xxx" + tracing: + additionalTraceHeaders: + enabled: true + traceContext: + parentId: "parentId" + traceId: "traceId" + traceParent: "traceParent" + traceState: "traceState" + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: "--hub.tracing.additionalTraceHeaders.traceContext.parentId=parentId" + - contains: + path: spec.template.spec.containers[0].args + content: "--hub.tracing.additionalTraceHeaders.traceContext.traceId=traceId" + - contains: + path: spec.template.spec.containers[0].args + content: "--hub.tracing.additionalTraceHeaders.traceContext.traceParent=traceParent" + - contains: + path: spec.template.spec.containers[0].args + content: "--hub.tracing.additionalTraceHeaders.traceContext.traceState=traceState" diff --git a/traefik/values.schema.json b/traefik/values.schema.json index 42801ce18..8ecab1c8c 100644 --- a/traefik/values.schema.json +++ b/traefik/values.schema.json @@ -358,6 +358,36 @@ }, "token": { "type": "string" + }, + "tracing": { + "properties": { + "additionalTraceHeaders": { + "properties": { + "enabled": { + "type": "boolean" + }, + "traceContext": { + "properties": { + "parentId": { + "type": "string" + }, + "traceId": { + "type": "string" + }, + "traceParent": { + "type": "string" + }, + "traceState": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" } }, "type": "object" diff --git a/traefik/values.yaml b/traefik/values.yaml index 3335e783d..4f9392437 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -979,3 +979,17 @@ hub: insecureSkipVerify: false # Enable export of errors logs to the platform. Default: true. sendlogs: # @schema type:[boolean, null] + tracing: + # -- Tracing headers to duplicate. + # To configure the following, tracing.otlp.enabled needs to be set to true. + additionalTraceHeaders: + enabled: false + traceContext: + # -- Name of the header that will contain the parent-id header copy. + parentId: "" + # -- Name of the header that will contain the trace-id copy. + traceId: "" + # -- Name of the header that will contain the traceparent copy. + traceParent: "" + # -- Name of the header that will contain the tracestate copy. + traceState: ""