Skip to content

Commit 9749d01

Browse files
authoredDec 10, 2024··
feat(Traefik Proxy): support NativeLB option in GatewayAPI provider
1 parent 2aad522 commit 9749d01

7 files changed

+28
-0
lines changed
 

‎traefik/VALUES.md

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Kubernetes: `>=1.22.0-0`
259259
| 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. |
260260
| providers.kubernetesGateway.labelselector | string | `""` | A label selector can be defined to filter on specific GatewayClass objects only. |
261261
| providers.kubernetesGateway.namespaces | list | `[]` | Array of namespaces to watch. If left empty, Traefik watches all namespaces. |
262+
| providers.kubernetesGateway.nativeLBByDefault | bool | `false` | Defines whether to use Native Kubernetes load-balancing mode by default. |
262263
| providers.kubernetesGateway.statusAddress.hostname | string | `""` | This Hostname will get copied to the Gateway status.addresses. |
263264
| 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). |
264265
| 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. |

‎traefik/templates/_podtemplate.tpl

+3
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@
533533
- "--providers.kubernetesgateway.statusaddress.service.namespace={{ tpl .namespace $ }}"
534534
{{- end }}
535535
{{- end }}
536+
{{- if .nativeLBByDefault }}
537+
- "--providers.kubernetesgateway.nativeLBByDefault=true"
538+
{{- end }}
536539
{{- if or .namespaces (and $.Values.rbac.enabled $.Values.rbac.namespaced) }}
537540
- "--providers.kubernetesgateway.namespaces={{ template "providers.kubernetesGateway.namespaces" $ }}"
538541
{{- end }}

‎traefik/templates/requirements.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@
3535
{{- if and (semverCompare "<v3.3.0-0" $version) (.Values.experimental.abortOnPluginFailure)}}
3636
{{- fail "ERROR: abortOnPluginFailure is an experimental feature only available for traefik >= v3.3.0." }}
3737
{{- end }}
38+
39+
{{- if and (semverCompare "<3.2.0-0" $version) (.Values.providers.kubernetesGateway.nativeLBByDefault)}}
40+
{{- fail "ERROR: nativeLBByDefault has been introduced in Kubernetes Gateway provider in v3.2.0" }}
41+
{{- end }}

‎traefik/tests/requirements-config_test.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ tests:
4343
asserts:
4444
- failedTemplate:
4545
errorMessage: "ERROR: Before traefik v3.1.0-rc3, kubernetesGateway is experimental. Enable it by setting experimental.kubernetesGateway.enabled to true"
46+
- it: should fail when using nativeLBByDefault on kubernetesGateway on traefik < 3.2
47+
set:
48+
image:
49+
tag: v3.1.0
50+
providers:
51+
kubernetesGateway:
52+
enabled: true
53+
nativeLBByDefault: true
54+
asserts:
55+
- failedTemplate:
56+
errorMessage: "ERROR: nativeLBByDefault has been introduced in Kubernetes Gateway provider in v3.2.0"
4657
- it: should not fail when using kubernetesGateway on traefik > 3.1.0-rc3 without experimental flag
4758
set:
4859
image:

‎traefik/tests/traefik-config_test.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ tests:
706706
kubernetesGateway:
707707
enabled: true
708708
experimentalChannel: true
709+
nativeLBByDefault: true
709710
labelselector: "app=traefik"
710711
asserts:
711712
- contains:
@@ -714,6 +715,9 @@ tests:
714715
- contains:
715716
path: spec.template.spec.containers[0].args
716717
content: "--providers.kubernetesgateway.labelselector=app=traefik"
718+
- contains:
719+
path: spec.template.spec.containers[0].args
720+
content: "--providers.kubernetesgateway.nativeLBByDefault=true"
717721
- it: should be possible to allow ACME bypass
718722
set:
719723
ports:

‎traefik/values.schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@
13571357
"namespaces": {
13581358
"type": "array"
13591359
},
1360+
"nativeLBByDefault": {
1361+
"type": "boolean"
1362+
},
13601363
"statusAddress": {
13611364
"properties": {
13621365
"hostname": {

‎traefik/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ providers: # @schema additionalProperties: false
305305
namespaces: []
306306
# -- A label selector can be defined to filter on specific GatewayClass objects only.
307307
labelselector: ""
308+
# -- Defines whether to use Native Kubernetes load-balancing mode by default.
309+
nativeLBByDefault: false
308310
statusAddress:
309311
# -- This IP will get copied to the Gateway status.addresses, and currently only supports one IP value (IPv4 or IPv6).
310312
ip: ""

0 commit comments

Comments
 (0)
Please sign in to comment.