diff --git a/traefik/VALUES.md b/traefik/VALUES.md index d5159aa9f..0b4e3a061 100644 --- a/traefik/VALUES.md +++ b/traefik/VALUES.md @@ -259,6 +259,7 @@ Kubernetes: `>=1.22.0-0` | providers.kubernetesGateway.experimentalChannel | bool | `false` | Toggles support for the Experimental Channel resources (Gateway API release channels documentation). This option currently enables support for TCPRoute and TLSRoute. | | providers.kubernetesGateway.labelselector | string | `""` | A label selector can be defined to filter on specific GatewayClass objects only. | | providers.kubernetesGateway.namespaces | list | `[]` | Array of namespaces to watch. If left empty, Traefik watches all namespaces. | +| providers.kubernetesGateway.nativeLBByDefault | bool | `false` | Defines whether to use Native Kubernetes load-balancing mode by default. | | providers.kubernetesGateway.statusAddress.hostname | string | `""` | This Hostname will get copied to the Gateway status.addresses. | | providers.kubernetesGateway.statusAddress.ip | string | `""` | This IP will get copied to the Gateway status.addresses, and currently only supports one IP value (IPv4 or IPv6). | | providers.kubernetesGateway.statusAddress.service | object | `{"name":"{{ (include \"traefik.fullname\" .) }}","namespace":"{{ .Release.Namespace }}"}` | The Kubernetes service to copy status addresses from. When using third parties tools like External-DNS, this option can be used to copy the service loadbalancer.status (containing the service's endpoints IPs) to the gateways. Default to Service of this Chart. | diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index f83bb62e2..51e1c4e2e 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -533,6 +533,9 @@ - "--providers.kubernetesgateway.statusaddress.service.namespace={{ tpl .namespace $ }}" {{- end }} {{- end }} + {{- if .nativeLBByDefault }} + - "--providers.kubernetesgateway.nativeLBByDefault=true" + {{- end }} {{- if or .namespaces (and $.Values.rbac.enabled $.Values.rbac.namespaced) }} - "--providers.kubernetesgateway.namespaces={{ template "providers.kubernetesGateway.namespaces" $ }}" {{- end }} diff --git a/traefik/templates/requirements.yaml b/traefik/templates/requirements.yaml index bab84c34b..e2387008b 100644 --- a/traefik/templates/requirements.yaml +++ b/traefik/templates/requirements.yaml @@ -35,3 +35,7 @@ {{- if and (semverCompare "= v3.3.0." }} {{- end }} + +{{- if and (semverCompare "<3.2.0-0" $version) (.Values.providers.kubernetesGateway.nativeLBByDefault)}} + {{- fail "ERROR: nativeLBByDefault has been introduced in Kubernetes Gateway provider in v3.2.0" }} +{{- end }} diff --git a/traefik/tests/requirements-config_test.yaml b/traefik/tests/requirements-config_test.yaml index a469c1242..2133870df 100644 --- a/traefik/tests/requirements-config_test.yaml +++ b/traefik/tests/requirements-config_test.yaml @@ -43,6 +43,17 @@ tests: asserts: - failedTemplate: errorMessage: "ERROR: Before traefik v3.1.0-rc3, kubernetesGateway is experimental. Enable it by setting experimental.kubernetesGateway.enabled to true" + - it: should fail when using nativeLBByDefault on kubernetesGateway on traefik < 3.2 + set: + image: + tag: v3.1.0 + providers: + kubernetesGateway: + enabled: true + nativeLBByDefault: true + asserts: + - failedTemplate: + errorMessage: "ERROR: nativeLBByDefault has been introduced in Kubernetes Gateway provider in v3.2.0" - it: should not fail when using kubernetesGateway on traefik > 3.1.0-rc3 without experimental flag set: image: diff --git a/traefik/tests/traefik-config_test.yaml b/traefik/tests/traefik-config_test.yaml index 139192a5f..ec8e89be5 100644 --- a/traefik/tests/traefik-config_test.yaml +++ b/traefik/tests/traefik-config_test.yaml @@ -706,6 +706,7 @@ tests: kubernetesGateway: enabled: true experimentalChannel: true + nativeLBByDefault: true labelselector: "app=traefik" asserts: - contains: @@ -714,6 +715,9 @@ tests: - contains: path: spec.template.spec.containers[0].args content: "--providers.kubernetesgateway.labelselector=app=traefik" + - contains: + path: spec.template.spec.containers[0].args + content: "--providers.kubernetesgateway.nativeLBByDefault=true" - it: should be possible to allow ACME bypass set: ports: diff --git a/traefik/values.schema.json b/traefik/values.schema.json index 3f62f424b..b3c233ca8 100644 --- a/traefik/values.schema.json +++ b/traefik/values.schema.json @@ -1357,6 +1357,9 @@ "namespaces": { "type": "array" }, + "nativeLBByDefault": { + "type": "boolean" + }, "statusAddress": { "properties": { "hostname": { diff --git a/traefik/values.yaml b/traefik/values.yaml index 9b4379cfa..d9794b18b 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -305,6 +305,8 @@ providers: # @schema additionalProperties: false namespaces: [] # -- A label selector can be defined to filter on specific GatewayClass objects only. labelselector: "" + # -- Defines whether to use Native Kubernetes load-balancing mode by default. + nativeLBByDefault: false statusAddress: # -- This IP will get copied to the Gateway status.addresses, and currently only supports one IP value (IPv4 or IPv6). ip: ""