From 85697f0cfbfae77539bfdb8ba8255e77735a762f Mon Sep 17 00:00:00 2001 From: Manuel Zapf Date: Fri, 16 Feb 2024 10:46:04 +0100 Subject: [PATCH] feat: create v1 Gateway and GatewayClass Version for Traefik v3 --- traefik/templates/gateway.yaml | 4 ++++ traefik/templates/gatewayclass.yaml | 4 ++++ traefik/tests/gateway-config_test.yaml | 14 ++++++++++++++ traefik/tests/gatewayclass-config_test.yaml | 14 ++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/traefik/templates/gateway.yaml b/traefik/templates/gateway.yaml index 7370bacdf..13eedc84a 100644 --- a/traefik/templates/gateway.yaml +++ b/traefik/templates/gateway.yaml @@ -1,6 +1,10 @@ {{- if .Values.experimental.kubernetesGateway.enabled }} --- +{{- if semverCompare ">=3.0.0-rc1" (default $.Chart.AppVersion $.Values.image.tag)}} +apiVersion: gateway.networking.k8s.io/v1 +{{- else }} apiVersion: gateway.networking.k8s.io/v1alpha2 +{{- end }} kind: Gateway metadata: name: traefik-gateway diff --git a/traefik/templates/gatewayclass.yaml b/traefik/templates/gatewayclass.yaml index c8abada08..0970008ad 100644 --- a/traefik/templates/gatewayclass.yaml +++ b/traefik/templates/gatewayclass.yaml @@ -1,6 +1,10 @@ {{- if .Values.experimental.kubernetesGateway.enabled }} --- +{{- if semverCompare ">=3.0.0-rc1" (default $.Chart.AppVersion $.Values.image.tag)}} +apiVersion: gateway.networking.k8s.io/v1 +{{- else }} apiVersion: gateway.networking.k8s.io/v1alpha2 +{{- end }} kind: GatewayClass metadata: name: traefik diff --git a/traefik/tests/gateway-config_test.yaml b/traefik/tests/gateway-config_test.yaml index 4dd5260e5..8b1d4a120 100644 --- a/traefik/tests/gateway-config_test.yaml +++ b/traefik/tests/gateway-config_test.yaml @@ -8,6 +8,9 @@ tests: kubernetesGateway: enabled: true asserts: + - containsDocument: + kind: Gateway + apiVersion: gateway.networking.k8s.io/v1alpha2 - equal: path: spec.gatewayClassName value: "traefik" @@ -41,6 +44,17 @@ tests: - equal: path: spec.listeners[1].allowedRoutes.namespaces.from value: "All" + - it: should set expected apiVersion with v3 version + set: + image: + tag: 3.0.0-rc1 + experimental: + kubernetesGateway: + enabled: true + asserts: + - containsDocument: + kind: Gateway + apiVersion: gateway.networking.k8s.io/v1 - it: should have one Gateway with the correct class and an http port as well as an https port set: experimental: diff --git a/traefik/tests/gatewayclass-config_test.yaml b/traefik/tests/gatewayclass-config_test.yaml index c60ca30e8..6169621c8 100644 --- a/traefik/tests/gatewayclass-config_test.yaml +++ b/traefik/tests/gatewayclass-config_test.yaml @@ -8,6 +8,20 @@ tests: kubernetesGateway: enabled: true asserts: + - containsDocument: + kind: GatewayClass + apiVersion: gateway.networking.k8s.io/v1alpha2 - equal: path: spec.controllerName value: traefik.io/gateway-controller + - it: should set expected apiVersion with v3 version + set: + image: + tag: 3.0.0-rc1 + experimental: + kubernetesGateway: + enabled: true + asserts: + - containsDocument: + kind: GatewayClass + apiVersion: gateway.networking.k8s.io/v1