Skip to content

Commit 63921d1

Browse files
authored
Move HTTPRouteRule and GRPCRouteRule 'name' fields to Standard (#3826)
* Promote HTTPRouteRule and GRPCRouteRule 'name' fields to Standard Signed-off-by: Guilherme Cassolato <[email protected]> * tests: conformance: httproute and grpcroute named rules Signed-off-by: Guilherme Cassolato <[email protected]> * tests: mesh conformance tests for httproute Signed-off-by: Guilherme Cassolato <[email protected]> * feature names: HTTPRouteNamedRouteRule and GRPCRouteNamedRouteRule Signed-off-by: Guilherme Cassolato <[email protected]> * fix: mesh conformance features and object name/namespace Signed-off-by: Guilherme Cassolato <[email protected]> * lint: fix var declaration and comment Signed-off-by: Guilherme Cassolato <[email protected]> * different name for HTTPRouteRuleNamedRouteRule feature for mesh Signed-off-by: Guilherme Cassolato <[email protected]> * conformance tests flagged as provisional Signed-off-by: Guilherme Cassolato <[email protected]> * fix: typo Signed-off-by: Guilherme Cassolato <[email protected]> --------- Signed-off-by: Guilherme Cassolato <[email protected]>
1 parent 564720a commit 63921d1

17 files changed

+360
-8
lines changed

apis/v1/grpcroute_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ type GRPCRouteRule struct {
156156
//
157157
// Support: Extended
158158
// +optional
159-
// <gateway:experimental>
160159
Name *SectionName `json:"name,omitempty"`
161160

162161
// Matches define conditions used for matching the rule against incoming

apis/v1/httproute_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ type HTTPRouteRule struct {
138138
//
139139
// Support: Extended
140140
// +optional
141-
// <gateway:experimental>
142141
Name *SectionName `json:"name,omitempty"`
143142

144143
// Matches define conditions used for matching the rule against incoming

config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/standard/gateway.networking.k8s.io_httproutes.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package tests
18+
19+
import (
20+
"testing"
21+
22+
"k8s.io/apimachinery/pkg/types"
23+
24+
v1 "sigs.k8s.io/gateway-api/apis/v1"
25+
pb "sigs.k8s.io/gateway-api/conformance/echo-basic/grpcechoserver"
26+
"sigs.k8s.io/gateway-api/conformance/utils/grpc"
27+
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
28+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
29+
"sigs.k8s.io/gateway-api/pkg/features"
30+
)
31+
32+
func init() {
33+
ConformanceTests = append(ConformanceTests, GRPCRouteNamedRule)
34+
}
35+
36+
var GRPCRouteNamedRule = suite.ConformanceTest{
37+
ShortName: "GRPCRouteNamedRule",
38+
Description: "An GRPCRoute with a named GRPCRouteRule",
39+
Manifests: []string{"tests/grpcroute-named-rule.yaml"},
40+
Features: []features.FeatureName{
41+
features.SupportGateway,
42+
features.SupportGRPCRoute,
43+
features.SupportGRPCRouteNamedRouteRule,
44+
},
45+
Provisional: true,
46+
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
47+
ns := "gateway-conformance-infra"
48+
routeNN := types.NamespacedName{Name: "grpc-named-rules", Namespace: ns}
49+
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
50+
gwAddr := kubernetes.GatewayAndRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), &v1.GRPCRoute{}, routeNN)
51+
52+
testCases := []grpc.ExpectedResponse{
53+
{
54+
EchoRequest: &pb.EchoRequest{},
55+
Backend: "grpc-infra-backend-v1",
56+
Namespace: ns,
57+
}, {
58+
EchoTwoRequest: &pb.EchoRequest{},
59+
Backend: "grpc-infra-backend-v2",
60+
Namespace: ns,
61+
},
62+
}
63+
64+
for i := range testCases {
65+
tc := testCases[i]
66+
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
67+
t.Parallel()
68+
grpc.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.GRPCClient, suite.TimeoutConfig, gwAddr, tc)
69+
})
70+
}
71+
},
72+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpc-named-rules
5+
namespace: gateway-conformance-infra
6+
spec:
7+
parentRefs:
8+
- name: same-namespace
9+
rules:
10+
- name: named-rule
11+
matches:
12+
- method:
13+
service: gateway_api_conformance.echo_basic.grpcecho.GrpcEcho
14+
method: Echo
15+
backendRefs:
16+
- name: grpc-infra-backend-v1
17+
port: 8080
18+
- matches:
19+
- method:
20+
service: gateway_api_conformance.echo_basic.grpcecho.GrpcEcho
21+
method: EchoTwo
22+
backendRefs:
23+
- name: grpc-infra-backend-v2
24+
port: 8080
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package tests
18+
19+
import (
20+
"testing"
21+
22+
"k8s.io/apimachinery/pkg/types"
23+
24+
"sigs.k8s.io/gateway-api/conformance/utils/http"
25+
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
26+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
27+
"sigs.k8s.io/gateway-api/pkg/features"
28+
)
29+
30+
func init() {
31+
ConformanceTests = append(ConformanceTests, HTTPRouteNamedRule)
32+
}
33+
34+
var HTTPRouteNamedRule = suite.ConformanceTest{
35+
ShortName: "HTTPRouteNamedRule",
36+
Description: "An HTTPRoute with a named HTTPRouteRule",
37+
Manifests: []string{"tests/httproute-named-rule.yaml"},
38+
Features: []features.FeatureName{
39+
features.SupportGateway,
40+
features.SupportHTTPRoute,
41+
features.SupportHTTPRouteNamedRouteRule,
42+
},
43+
Provisional: true,
44+
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
45+
ns := "gateway-conformance-infra"
46+
routeNN := types.NamespacedName{Name: "http-named-rules", Namespace: ns}
47+
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
48+
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
49+
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)
50+
51+
testCases := []http.ExpectedResponse{
52+
{
53+
Request: http.Request{Path: "/named"},
54+
Response: http.Response{StatusCode: 200},
55+
Namespace: ns,
56+
}, {
57+
Request: http.Request{Path: "/unnamed"},
58+
Response: http.Response{StatusCode: 200},
59+
Namespace: ns,
60+
},
61+
}
62+
63+
for i := range testCases {
64+
tc := testCases[i]
65+
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
66+
t.Parallel()
67+
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, tc)
68+
})
69+
}
70+
},
71+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: http-named-rules
5+
namespace: gateway-conformance-infra
6+
spec:
7+
parentRefs:
8+
- name: same-namespace
9+
rules:
10+
- name: named-rule
11+
matches:
12+
- path:
13+
type: PathPrefix
14+
value: /named
15+
backendRefs:
16+
- name: infra-backend-v1
17+
port: 8080
18+
- matches:
19+
- path:
20+
type: PathPrefix
21+
value: /unnamed
22+
backendRefs:
23+
- name: infra-backend-v2
24+
port: 8080
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package meshtests
18+
19+
import (
20+
"testing"
21+
22+
"sigs.k8s.io/gateway-api/conformance/utils/echo"
23+
"sigs.k8s.io/gateway-api/conformance/utils/http"
24+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25+
"sigs.k8s.io/gateway-api/pkg/features"
26+
)
27+
28+
func init() {
29+
MeshConformanceTests = append(MeshConformanceTests, MeshHTTPRouteNamedRule)
30+
}
31+
32+
var MeshHTTPRouteNamedRule = suite.ConformanceTest{
33+
ShortName: "MeshHTTPRouteNamedRule",
34+
Description: "An HTTPRoute with a named HTTPRouteRule",
35+
Manifests: []string{"tests/mesh/httproute-named-rule.yaml"},
36+
Features: []features.FeatureName{
37+
features.SupportMesh,
38+
features.SupportHTTPRoute,
39+
features.SupportMeshHTTPRouteNamedRouteRule,
40+
},
41+
Provisional: true,
42+
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
43+
ns := "gateway-conformance-mesh"
44+
client := echo.ConnectToApp(t, suite, echo.MeshAppEchoV1)
45+
46+
testCases := []http.ExpectedResponse{
47+
{
48+
Request: http.Request{Path: "/named"},
49+
ExpectedRequest: &http.ExpectedRequest{Request: http.Request{Path: "/named"}},
50+
Backend: "echo-v1",
51+
Namespace: ns,
52+
}, {
53+
Request: http.Request{Path: "/unnamed"},
54+
ExpectedRequest: &http.ExpectedRequest{Request: http.Request{Path: "/named"}},
55+
Backend: "echo-v2",
56+
Namespace: ns,
57+
},
58+
}
59+
60+
for i := range testCases {
61+
tc := testCases[i]
62+
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
63+
t.Parallel()
64+
client.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, suite.TimeoutConfig)
65+
})
66+
}
67+
},
68+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: mesh-http-named-rules
5+
namespace: gateway-conformance-mesh
6+
spec:
7+
parentRefs:
8+
- group: ""
9+
kind: Service
10+
name: echo
11+
port: 80
12+
rules:
13+
- name: named-rule
14+
matches:
15+
- path:
16+
type: PathPrefix
17+
value: /named
18+
backendRefs:
19+
- name: echo-v1
20+
port: 8080
21+
- matches:
22+
- path:
23+
type: PathPrefix
24+
value: /unnamed
25+
backendRefs:
26+
- name: echo-v2
27+
port: 8080

0 commit comments

Comments
 (0)