diff --git a/CHANGELOG.md b/CHANGELOG.md index 227791213a..7f39f0c16f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,10 @@ Adding a new version? You'll need three changes: ### Fixed +- Set `protocols` field to `[http,https]` in translated routes in expression + router mode. + [#7860](https://github.com/Kong/kubernetes-ingress-controller/pull/7860) + - Fixed an issue with SNI generation in dbless mode. [#7853](https://github.com/Kong/kubernetes-ingress-controller/pull/7853) diff --git a/internal/dataplane/testdata/golden/grpcroute-example/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/grpcroute-example/expression-routes-on_golden.yaml index 2845196c6d..be071d24eb 100644 --- a/internal/dataplane/testdata/golden/grpcroute-example/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/grpcroute-example/expression-routes-on_golden.yaml @@ -19,6 +19,9 @@ services: name: grpcroute.default.grpcbin.example.com.2.0 preserve_host: true priority: 26766487871743 + protocols: + - http + - https tags: - k8s-name:grpcbin - k8s-namespace:default @@ -54,6 +57,9 @@ services: name: grpcroute.default.grpcbin.example.com.1.0 preserve_host: true priority: 26766487904511 + protocols: + - http + - https tags: - k8s-name:grpcbin - k8s-namespace:default @@ -89,6 +95,9 @@ services: name: grpcroute.default.grpcbin.example.com.0.0 preserve_host: true priority: 26766487929087 + protocols: + - http + - https tags: - k8s-name:grpcbin - k8s-namespace:default diff --git a/internal/dataplane/testdata/golden/httproute-example/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/httproute-example/expression-routes-on_golden.yaml index 15d23e745a..445cab6e58 100644 --- a/internal/dataplane/testdata/golden/httproute-example/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/httproute-example/expression-routes-on_golden.yaml @@ -15,6 +15,9 @@ services: name: httproute.default.httproute-testing._.3.0 preserve_host: true priority: 35184414035967 + protocols: + - http + - https strip_path: true tags: - k8s-name:httproute-testing @@ -43,6 +46,9 @@ services: name: httproute.default.httproute-testing._.2.0 preserve_host: true priority: 35184430813183 + protocols: + - http + - https strip_path: true tags: - k8s-name:httproute-testing @@ -57,6 +63,9 @@ services: name: httproute.default.httproute-testing._.1.0 preserve_host: true priority: 35184405647359 + protocols: + - http + - https strip_path: true tags: - k8s-name:httproute-testing @@ -86,6 +95,9 @@ services: name: httproute.default.httproute-testing._.0.0 preserve_host: true priority: 35184514699263 + protocols: + - http + - https strip_path: true tags: - k8s-name:httproute-testing diff --git a/internal/dataplane/testdata/golden/httproute-url-rewrite-path-prefix/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/httproute-url-rewrite-path-prefix/expression-routes-on_golden.yaml index 1b8eba5a72..f98b6ba6c6 100644 --- a/internal/dataplane/testdata/golden/httproute-url-rewrite-path-prefix/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/httproute-url-rewrite-path-prefix/expression-routes-on_golden.yaml @@ -26,6 +26,9 @@ services: - k8s-version:v1 preserve_host: true priority: 35184422424575 + protocols: + - http + - https strip_path: false tags: - k8s-name:httproute-testing diff --git a/internal/dataplane/testdata/golden/ingress-v1-empty-path/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-empty-path/expression-routes-on_golden.yaml index 73f5991552..59171ef8a8 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-empty-path/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-empty-path/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.foo-svc.example.com.80 preserve_host: true priority: 57178899611649 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-multiple-ports-for-one-service/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-multiple-ports-for-one-service/expression-routes-on_golden.yaml index adadd78f1a..557939f7ec 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-multiple-ports-for-one-service/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-multiple-ports-for-one-service/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.foo-svc.example.net.8000 preserve_host: true priority: 57178899611649 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false @@ -49,6 +52,9 @@ services: name: foo-namespace.foo.foo-svc.example.com.80 preserve_host: true priority: 57178899611649 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-ports-defined-by-name/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-ports-defined-by-name/expression-routes-on_golden.yaml index 4bf47ec38a..fbace8d4e2 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-ports-defined-by-name/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-ports-defined-by-name/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.regex-prefix.foo-svc.example.com.http preserve_host: true priority: 57178899611649 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-regex-prefix-exact-rule/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-regex-prefix-exact-rule/expression-routes-on_golden.yaml index 0aa89f9ff8..41c232aad0 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-regex-prefix-exact-rule/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-regex-prefix-exact-rule/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.foo-svc.example.com.80 preserve_host: true priority: 57178899677193 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-regex-prefixed-path/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-regex-prefixed-path/expression-routes-on_golden.yaml index 64b609a8f7..e4f4d699df 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-regex-prefixed-path/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-regex-prefixed-path/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.regex-prefix.foo-svc.example.com.80 preserve_host: true priority: 57178899677194 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/expression-routes-on_golden.yaml index c3d011b12c..2b83eb1e51 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/expression-routes-on_golden.yaml @@ -67,6 +67,9 @@ services: name: bar-namespace.ing-with-tls.foo-svc.example.com.80 preserve_host: true priority: 57178899677185 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/note.txt b/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/note.txt deleted file mode 100644 index 0fa578bf08..0000000000 --- a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls-and-consumer-ee/note.txt +++ /dev/null @@ -1,10 +0,0 @@ -This test case is EE only because behavior change in https://github.com/Kong/kubernetes-ingress-controller/pull/7853 -made rendering SNIs work with newer versions of Kong but at the same time made it -incompatible with older versions. -Since there is no OSS version of Kong newer than 3.9 we cannot run this against OSS -for the plain reason of there not being a new enough version to test the change. -The golden files framework does not account for generating golden files for -multiple Kong version, that would require changes in -https://github.com/Kong/kubernetes-ingress-controller/blob/a7bf8059c924e93241a973b96bac6c76b6a84d97/internal/dataplane/kong_client_golden_test.go - -Related PR in KIC 3.4: https://github.com/Kong/kubernetes-ingress-controller/pull/6660 diff --git a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls/expression-routes-on_golden.yaml index 3959234416..de30e9e6fe 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-rule-with-tls/expression-routes-on_golden.yaml @@ -83,6 +83,9 @@ services: name: bar-namespace.ing-with-tls.foo-svc.example.com.80 preserve_host: true priority: 57178899677185 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-single-service-in-multiple-ingresses/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-single-service-in-multiple-ingresses/expression-routes-on_golden.yaml index 364d354e49..791a8a9ad3 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-single-service-in-multiple-ingresses/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-single-service-in-multiple-ingresses/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.foo-svc.example.com.80 preserve_host: true priority: 57178899677185 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false @@ -31,6 +34,9 @@ services: name: foo-namespace.foo-2.foo-svc.example.com.80 preserve_host: true priority: 57178899677185 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-with-acme-like-path/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-with-acme-like-path/expression-routes-on_golden.yaml index 83d338b291..c2db0f55ec 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-with-acme-like-path/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-with-acme-like-path/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.cert-manager-solver-pod.example.com.80 preserve_host: true priority: 57178899611680 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/ingress-v1-with-default-backend/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/ingress-v1-with-default-backend/expression-routes-on_golden.yaml index e8eeda84e8..63d6365c1d 100644 --- a/internal/dataplane/testdata/golden/ingress-v1-with-default-backend/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/ingress-v1-with-default-backend/expression-routes-on_golden.yaml @@ -16,6 +16,9 @@ services: name: foo-namespace.foo.foo-svc.example.com.80 preserve_host: true priority: 57178899677185 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false @@ -47,6 +50,9 @@ services: name: bar-namespace.ing-with-default-backend preserve_host: true priority: 0 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/testdata/golden/kong-service-facade/expression-routes-on_golden.yaml b/internal/dataplane/testdata/golden/kong-service-facade/expression-routes-on_golden.yaml index 2c922e023a..598bba543d 100644 --- a/internal/dataplane/testdata/golden/kong-service-facade/expression-routes-on_golden.yaml +++ b/internal/dataplane/testdata/golden/kong-service-facade/expression-routes-on_golden.yaml @@ -35,6 +35,9 @@ services: name: default.beta preserve_host: true priority: 0 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false @@ -67,6 +70,9 @@ services: name: default.beta..svc-facade-beta.svc.facade preserve_host: true priority: 54975581454341 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false @@ -99,6 +105,9 @@ services: name: default.alpha..svc-facade-alpha.svc.facade preserve_host: true priority: 54975581454342 + protocols: + - http + - https request_buffering: true response_buffering: true strip_path: false diff --git a/internal/dataplane/translator/subtranslator/grpcroute_atc.go b/internal/dataplane/translator/subtranslator/grpcroute_atc.go index 8f90b60923..83c1b74019 100644 --- a/internal/dataplane/translator/subtranslator/grpcroute_atc.go +++ b/internal/dataplane/translator/subtranslator/grpcroute_atc.go @@ -39,7 +39,8 @@ func GenerateKongExpressionRoutesFromGRPCRouteRule(grpcroute *gatewayapi.GRPCRou r := kongstate.Route{ Ingress: ingressObjectInfo, Route: kong.Route{ - Name: kong.String(routeName), + Name: kong.String(routeName), + Protocols: kong.StringSlice("http", "https"), }, ExpressionRoutes: true, } @@ -62,7 +63,8 @@ func GenerateKongExpressionRoutesFromGRPCRouteRule(grpcroute *gatewayapi.GRPCRou r := kongstate.Route{ Ingress: ingressObjectInfo, Route: kong.Route{ - Name: kong.String(routeName), + Name: kong.String(routeName), + Protocols: kong.StringSlice("http", "https"), }, ExpressionRoutes: true, } @@ -475,6 +477,7 @@ func KongExpressionRouteFromSplitGRPCRouteMatchWithPriority( r := kongstate.Route{ Route: kong.Route{ Name: kong.String(routeName), + Protocols: kong.StringSlice("http", "https"), PreserveHost: kong.Bool(true), Tags: tags, }, diff --git a/internal/dataplane/translator/subtranslator/grpcroute_atc_test.go b/internal/dataplane/translator/subtranslator/grpcroute_atc_test.go index b3c2f7fbb0..9a5fb06c91 100644 --- a/internal/dataplane/translator/subtranslator/grpcroute_atc_test.go +++ b/internal/dataplane/translator/subtranslator/grpcroute_atc_test.go @@ -57,6 +57,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.single-match.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path ^= "/service0/") && (http.headers.x_foo == "Bar")`), Priority: kong.Uint64(1), }, @@ -89,6 +90,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.single-match-with-hostname.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path == "/service0/method0") && ((http.host == "foo.com") || (http.host =^ ".foo.com"))`), Priority: kong.Uint64(1), }, @@ -134,6 +136,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.multiple-matches.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path =^ "/method0") && ((http.headers.client == "kong-test") && (http.headers.version == "2"))`), Priority: kong.Uint64(1), }, @@ -147,6 +150,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.multiple-matches.0.1"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`http.path ~ "^/v[012]/.+"`), Priority: kong.Uint64(1), }, @@ -186,6 +190,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.single-match-with-annotations.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path == "/service0/method0") && (tls.sni == "kong.foo.com")`), Priority: kong.Uint64(1), }, @@ -209,6 +214,7 @@ func TestGenerateKongExpressionRoutesFromGRPCRouteRule(t *testing.T) { ExpressionRoutes: true, Route: kong.Route{ Name: kong.String("grpcroute.default.hostname-only.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`http.host == "foo.com"`), Priority: kong.Uint64(1), }, @@ -1118,6 +1124,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) { expectedRoute: kongstate.Route{ Route: kong.Route{ Name: kong.String("grpcroute.default.no-hostname-exact-method._.0.0"), + Protocols: kong.StringSlice("http", "https"), PreserveHost: kong.Bool(true), Expression: kong.String(`http.path == "/pets/list"`), Priority: kong.Uint64(1 << 14), @@ -1170,6 +1177,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) { expectedRoute: kongstate.Route{ Route: kong.Route{ Name: kong.String("grpcroute.default.precise-hostname-regex-method.foo.com.0.0"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path ~ "^/name/[a-z0-9]+") && (http.host == "foo.com")`), PreserveHost: kong.Bool(true), Priority: kong.Uint64((1 << 31) + 1), @@ -1239,6 +1247,7 @@ func TestKongExpressionRouteFromSplitGRPCRouteWithPriority(t *testing.T) { expectedRoute: kongstate.Route{ Route: kong.Route{ Name: kong.String("grpcroute.default.wildcard-hostname-header-match._.foo.com.0.1"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.path ^= "/name/") && (http.headers.foo == "bar") && (http.host =^ ".foo.com")`), PreserveHost: kong.Bool(true), Priority: kong.Uint64((1 << 42) + 1), diff --git a/internal/dataplane/translator/subtranslator/httproute_atc.go b/internal/dataplane/translator/subtranslator/httproute_atc.go index 13598ce84c..fd11d4461f 100644 --- a/internal/dataplane/translator/subtranslator/httproute_atc.go +++ b/internal/dataplane/translator/subtranslator/httproute_atc.go @@ -499,6 +499,7 @@ func kongExpressionRouteFromHTTPRouteMatchWithPriority( Route: kong.Route{ Name: kong.String(routeName), PreserveHost: kong.Bool(true), + Protocols: kong.StringSlice("http", "https"), // stripPath needs to be disabled by default to be conformant with the Gateway API StripPath: kong.Bool(false), Tags: tags, diff --git a/internal/dataplane/translator/subtranslator/httproute_atc_test.go b/internal/dataplane/translator/subtranslator/httproute_atc_test.go index 20f6d781ce..9db53c7f3c 100644 --- a/internal/dataplane/translator/subtranslator/httproute_atc_test.go +++ b/internal/dataplane/translator/subtranslator/httproute_atc_test.go @@ -1218,6 +1218,7 @@ func TestKongExpressionRouteFromHTTPRouteMatchWithPriority(t *testing.T) { require.NoError(t, err) require.Equal(t, tc.routeName, *route.Name, "Should have expected route name") + require.ElementsMatch(t, lo.ToSlicePtr([]string{"http", "https"}), route.Protocols) require.True(t, route.ExpressionRoutes, "Should be expression route") require.Equal(t, tc.routeExpresion, *route.Expression, "Should translate to expected expression") require.Equal(t, tc.priority, *route.Priority, "Should have expected priority") diff --git a/internal/dataplane/translator/subtranslator/ingress_atc.go b/internal/dataplane/translator/subtranslator/ingress_atc.go index af021412d8..6c26d1be54 100644 --- a/internal/dataplane/translator/subtranslator/ingress_atc.go +++ b/internal/dataplane/translator/subtranslator/ingress_atc.go @@ -42,6 +42,7 @@ func (m *ingressTranslationMeta) translateIntoKongExpressionRoute() *kongstate.R Ingress: util.FromK8sObject(m.parentIngress), Route: kong.Route{ Name: kong.String(routeName), + Protocols: kong.StringSlice("http", "https"), StripPath: kong.Bool(false), PreserveHost: kong.Bool(true), RequestBuffering: kong.Bool(true), diff --git a/internal/dataplane/translator/subtranslator/ingress_atc_test.go b/internal/dataplane/translator/subtranslator/ingress_atc_test.go index 98a4fd4dbf..ff9cefa529 100644 --- a/internal/dataplane/translator/subtranslator/ingress_atc_test.go +++ b/internal/dataplane/translator/subtranslator/ingress_atc_test.go @@ -82,6 +82,7 @@ func TestTranslateIngressATC(t *testing.T) { }, Route: kong.Route{ Name: kong.String("default.test-ingress.test-service.konghq.com.80"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.host == "konghq.com") && ((http.path == "/api") || (http.path ^= "/api/"))`), Priority: kong.Uint64(IngressRoutePriorityTraits{ MatchFields: 2, @@ -158,6 +159,7 @@ func TestTranslateIngressATC(t *testing.T) { }, Route: kong.Route{ Name: kong.String("default.test-ingress.test-service.konghq.com.80"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.host == "konghq.com") && (http.path ^= "/api/")`), Priority: kong.Uint64(IngressRoutePriorityTraits{ MatchFields: 2, @@ -244,6 +246,7 @@ func TestTranslateIngressATC(t *testing.T) { }, Route: kong.Route{ Name: kong.String("default.test-ingress-annotations.test-service.konghq.com.80"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.host == "konghq.com") && (http.path ^= "/api/") && (http.headers.foo == "bar") && (http.method == "GET")`), Priority: kong.Uint64(IngressRoutePriorityTraits{ MatchFields: 4, @@ -348,6 +351,7 @@ func TestTranslateIngressATC(t *testing.T) { }, Route: kong.Route{ Name: kong.String("default.test-ingress.konghq.com.svc-facade.svc.facade"), + Protocols: kong.StringSlice("http", "https"), Expression: kong.String(`(http.host == "konghq.com") && (http.path ^= "/api/")`), Priority: kong.Uint64(IngressRoutePriorityTraits{ MatchFields: 2, diff --git a/internal/dataplane/translator/translate_ingress.go b/internal/dataplane/translator/translate_ingress.go index 5785d7cf85..ae0d8bb20e 100644 --- a/internal/dataplane/translator/translate_ingress.go +++ b/internal/dataplane/translator/translate_ingress.go @@ -245,6 +245,7 @@ func translateIngressDefaultBackendRoute(ingress *netv1.Ingress, tags []*string, Ingress: util.FromK8sObject(ingress), Route: kong.Route{ Name: kong.String(ingress.Namespace + "." + ingress.Name), + Protocols: kong.StringSlice("http", "https"), StripPath: kong.Bool(false), PreserveHost: kong.Bool(true), RequestBuffering: kong.Bool(true), @@ -262,7 +263,6 @@ func translateIngressDefaultBackendRoute(ingress *netv1.Ingress, tags []*string, atc.ApplyExpression(&r.Route, catchAllMatcher, subtranslator.IngressDefaultBackendPriority) } else { r.Paths = kong.StringSlice("/") - r.Protocols = kong.StringSlice("http", "https") r.RegexPriority = kong.Int(0) } return r diff --git a/internal/dataplane/translator/translate_ingress_test.go b/internal/dataplane/translator/translate_ingress_test.go index 72db5a5f75..7710f838af 100644 --- a/internal/dataplane/translator/translate_ingress_test.go +++ b/internal/dataplane/translator/translate_ingress_test.go @@ -360,6 +360,7 @@ func TestGetDefaultBackendService(t *testing.T) { require.Equal(t, tc.expectedServiceHost, *svc.Host) require.Len(t, svc.Routes, 1) route := svc.Routes[0] + require.ElementsMatch(t, lo.ToSlicePtr([]string{"http", "https"}), route.Protocols) if tc.featureFlags.ExpressionRoutes { require.Equal(t, `(http.path ^= "/") && ((net.protocol == "http") || (net.protocol == "https"))`, *route.Expression) require.Equal(t, subtranslator.IngressDefaultBackendPriority, *route.Priority)