From 0b1d149a9b16838fbcea263b7eb7e67778c2b90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20BUISSON?= Date: Mon, 13 Jan 2025 14:58:04 +0100 Subject: [PATCH] chore(Gateway API): :recycle: remove template from values --- traefik/VALUES.md | 2 +- traefik/templates/_podtemplate.tpl | 6 +++--- traefik/tests/traefik-config_test.yaml | 17 ++++++++++++++++- traefik/values.schema.json | 3 +++ traefik/values.yaml | 5 +++-- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/traefik/VALUES.md b/traefik/VALUES.md index 90595b4e9..897efe006 100644 --- a/traefik/VALUES.md +++ b/traefik/VALUES.md @@ -265,7 +265,7 @@ Kubernetes: `>=1.22.0-0` | 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":"{{ include \"traefik.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. | +| providers.kubernetesGateway.statusAddress.service | object | `{"enabled":true,"name":"","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. | | providers.kubernetesIngress.allowEmptyServices | bool | `true` | Allows to return 503 when there is no endpoints available | | providers.kubernetesIngress.allowExternalNameServices | bool | `false` | Allows to reference ExternalName services in Ingress | | providers.kubernetesIngress.enabled | bool | `true` | Load Kubernetes Ingress provider | diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index ef8d79b6b..0b440782d 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -563,9 +563,9 @@ {{- with .hostname }} - "--providers.kubernetesgateway.statusaddress.hostname={{ . }}" {{- end }} - {{- with .service }} - - "--providers.kubernetesgateway.statusaddress.service.name={{ tpl .name $ }}" - - "--providers.kubernetesgateway.statusaddress.service.namespace={{ tpl .namespace $ }}" + {{- if (and .service.enabled $.Values.service.enabled) }} + - "--providers.kubernetesgateway.statusaddress.service.name={{ .service.name | default (include "traefik.fullname" $) }}" + - "--providers.kubernetesgateway.statusaddress.service.namespace={{ .service.namespace | default (include "traefik.namespace" $) }}" {{- end }} {{- end }} {{- if .nativeLBByDefault }} diff --git a/traefik/tests/traefik-config_test.yaml b/traefik/tests/traefik-config_test.yaml index c395ba345..a4ef8e8af 100644 --- a/traefik/tests/traefik-config_test.yaml +++ b/traefik/tests/traefik-config_test.yaml @@ -79,7 +79,7 @@ tests: - contains: path: spec.template.spec.containers[0].args content: "--providers.kubernetesingress.ingressendpoint.publishedservice=NAMESPACE/RELEASE-NAME-traefik" - - it: should use overrided namespace when specified + - it: should use override namespace when specified set: namespaceOverride: foo asserts: @@ -129,6 +129,21 @@ tests: - notContains: path: spec.template.spec.containers[0].args content: "--providers.kubernetesgateway.statusaddress.service.namespace=NAMESPACE" + - it: should not set default statusAddress when disabled + set: + providers: + kubernetesGateway: + enabled: true + statusAddress: + service: + enabled: false + asserts: + - notContains: + path: spec.template.spec.containers[0].args + content: "--providers.kubernetesgateway.statusaddress.service.name=RELEASE-NAME-traefik" + - notContains: + path: spec.template.spec.containers[0].args + content: "--providers.kubernetesgateway.statusaddress.service.namespace=NAMESPACE" - it: should be possible to set statusAddress fields set: providers: diff --git a/traefik/values.schema.json b/traefik/values.schema.json index 026096b06..53a4b9b5a 100644 --- a/traefik/values.schema.json +++ b/traefik/values.schema.json @@ -1394,6 +1394,9 @@ }, "service": { "properties": { + "enabled": { + "type": "boolean" + }, "name": { "type": "string" }, diff --git a/traefik/values.yaml b/traefik/values.yaml index 1575ab0b2..f5922fe96 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -319,8 +319,9 @@ providers: # @schema additionalProperties: false hostname: "" # -- 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. service: - name: "{{ .Values.service.enabled | ternary (include \"traefik.fullname\" .) nil }}" - namespace: "{{ .Values.service.enabled | ternary (include \"traefik.namespace\" .) nil }}" + enabled: true + name: "" + namespace: "" file: # -- Create a file provider