diff --git a/traefik/templates/gateway.yaml b/traefik/templates/gateway.yaml index 560a8686b..13696dffc 100644 --- a/traefik/templates/gateway.yaml +++ b/traefik/templates/gateway.yaml @@ -34,7 +34,7 @@ spec: port: {{ .port }} protocol: {{ .protocol }} {{- with .hostname }} - hostname: {{ . }} + hostname: {{ . | toYaml }} {{- end }} {{- with .namespacePolicy }} allowedRoutes: diff --git a/traefik/tests/gateway-config_test.yaml b/traefik/tests/gateway-config_test.yaml index d2c85104e..fd19722b1 100644 --- a/traefik/tests/gateway-config_test.yaml +++ b/traefik/tests/gateway-config_test.yaml @@ -180,7 +180,7 @@ tests: - equal: path: spec.listeners[0].protocol value: TCP - - it: should be possible to set hostname + - it: should be possible to set regular hostname set: providers: kubernetesGateway: @@ -193,6 +193,19 @@ tests: - equal: path: spec.listeners[0].hostname value: test.docker.localhost + - it: should be possible to set hostname with wildcard + set: + providers: + kubernetesGateway: + enabled: true + gateway: + listeners: + web: + hostname: "*.docker.localhost" + asserts: + - equal: + path: spec.listeners[0].hostname + value: "*.docker.localhost" - it: should fail when no listeners are defined set: providers: