Skip to content

Commit 9fb1d37

Browse files
authored
Update gateway api version to 1.2.0 (#2694)
Upgrade the gateway api version to v1.2.0 Problem: Need to upgrade the gateway-api version from 1.1.0 -> 1.2.0 Solution: Update gateway-api version to 1.2.0 and made other necessary updates to be integrated with NGF.
1 parent f2da836 commit 9fb1d37

File tree

12 files changed

+118
-26
lines changed

12 files changed

+118
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The following table lists the software versions NGINX Gateway Fabric supports.
6666

6767
| NGINX Gateway Fabric | Gateway API | Kubernetes | NGINX OSS | NGINX Plus |
6868
|----------------------|-------------|------------|-----------|------------|
69-
| Edge | 1.1.0 | 1.25+ | 1.27.2 | R32 |
69+
| Edge | 1.2.0 | 1.25+ | 1.27.2 | R32 |
7070
| 1.4.0 | 1.1.0 | 1.25+ | 1.27.1 | R32 |
7171
| 1.3.0 | 1.1.0 | 1.25+ | 1.27.0 | R32 |
7272
| 1.2.0 | 1.0.0 | 1.23+ | 1.25.4 | R31 |

cmd/gateway/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
const (
17-
// Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v1.1.0/apis/v1/shared_types.go#L647
17+
// Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v1.2.0/apis/v1/shared_types.go#L647
1818
controllerNameRegex = `^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` //nolint:lll
1919
)
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
4-
- https://github.com/kubernetes-sigs/gateway-api/config/crd/experimental?timeout=120&ref=v1.1.0
4+
- https://github.com/kubernetes-sigs/gateway-api/config/crd/experimental?timeout=120&ref=v1.2.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
4-
- https://github.com/kubernetes-sigs/gateway-api/config/crd?timeout=120&ref=v1.1.0
4+
- https://github.com/kubernetes-sigs/gateway-api/config/crd?timeout=120&ref=v1.2.0

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
k8s.io/client-go v0.31.1
2626
k8s.io/klog/v2 v2.130.1
2727
sigs.k8s.io/controller-runtime v0.19.0
28-
sigs.k8s.io/gateway-api v1.1.0
28+
sigs.k8s.io/gateway-api v1.2.0
2929
)
3030

3131
require (
@@ -84,7 +84,7 @@ require (
8484
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
8585
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
8686
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
87-
google.golang.org/grpc v1.66.1 // indirect
87+
google.golang.org/grpc v1.66.2 // indirect
8888
google.golang.org/protobuf v1.34.2 // indirect
8989
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9090
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:
198198
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
199199
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
200200
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
201-
google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM=
202-
google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
201+
google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo=
202+
google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
203203
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
204204
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
205205
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -230,8 +230,8 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1
230230
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
231231
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
232232
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
233-
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
234-
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
233+
sigs.k8s.io/gateway-api v1.2.0 h1:LrToiFwtqKTKZcZtoQPTuo3FxhrrhTgzQG0Te+YGSo8=
234+
sigs.k8s.io/gateway-api v1.2.0/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0=
235235
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
236236
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
237237
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

internal/framework/gatewayclass/validate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
// BundleVersionAnnotation is the annotation on Gateway API CRDs that contains the installed version.
1414
BundleVersionAnnotation = "gateway.networking.k8s.io/bundle-version"
1515
// SupportedVersion is the supported version of the Gateway API CRDs.
16-
SupportedVersion = "v1.1.0"
16+
SupportedVersion = "v1.2.0"
1717
)
1818

1919
var gatewayCRDs = map[string]apiVersion{

internal/mode/static/state/graph/grpcroute.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func validateGRPCMatch(
232232

233233
for j, h := range match.Headers {
234234
headerPath := matchPath.Child("headers").Index(j)
235-
allErrs = append(allErrs, validateHeaderMatch(validator, h.Type, string(h.Name), h.Value, headerPath)...)
235+
allErrs = append(allErrs, validateGRPCHeaderMatch(validator, h.Type, string(h.Name), h.Value, headerPath)...)
236236
}
237237

238238
return allErrs
@@ -277,3 +277,27 @@ func validateGRPCMethodMatch(
277277
}
278278
return allErrs
279279
}
280+
281+
func validateGRPCHeaderMatch(
282+
validator validation.HTTPFieldsValidator,
283+
headerType *v1.GRPCHeaderMatchType,
284+
headerName, headerValue string,
285+
headerPath *field.Path,
286+
) field.ErrorList {
287+
var allErrs field.ErrorList
288+
289+
if headerType == nil {
290+
allErrs = append(allErrs, field.Required(headerPath.Child("type"), "cannot be empty"))
291+
} else if *headerType != v1.GRPCHeaderMatchExact {
292+
valErr := field.NotSupported(
293+
headerPath.Child("type"),
294+
*headerType,
295+
[]string{string(v1.GRPCHeaderMatchExact)},
296+
)
297+
allErrs = append(allErrs, valErr)
298+
}
299+
300+
allErrs = append(allErrs, validateHeaderMatchNameAndValue(validator, headerName, headerValue, headerPath)...)
301+
302+
return allErrs
303+
}

internal/mode/static/state/graph/grpcroute_test.go

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func createGRPCHeadersMatch(headerType, headerName, headerValue string) v1.GRPCR
4242
{
4343
Headers: []v1.GRPCHeaderMatch{
4444
{
45-
Type: (*v1.HeaderMatchType)(&headerType),
45+
Type: (*v1.GRPCHeaderMatchType)(&headerType),
4646
Name: v1.GRPCHeaderName(headerName),
4747
Value: headerValue,
4848
},
@@ -242,6 +242,19 @@ func TestBuildGRPCRoute(t *testing.T) {
242242
methodMatchNilType := createGRPCMethodMatch("myService", "myMethod", "nilType")
243243
headersMatchInvalid := createGRPCHeadersMatch("", "MyHeader", "SomeValue")
244244

245+
headersMatchEmptyType := v1.GRPCRouteRule{
246+
Matches: []v1.GRPCRouteMatch{
247+
{
248+
Headers: []v1.GRPCHeaderMatch{
249+
{
250+
Name: v1.GRPCHeaderName("MyHeader"),
251+
Value: "SomeValue",
252+
},
253+
},
254+
},
255+
},
256+
}
257+
245258
grBoth := createGRPCRoute(
246259
"gr-1",
247260
gatewayNsName.Name,
@@ -290,12 +303,19 @@ func TestBuildGRPCRoute(t *testing.T) {
290303
"example.com",
291304
[]v1.GRPCRouteRule{methodMatchNilType},
292305
)
293-
grInvalidHeadersEmptyType := createGRPCRoute(
306+
grInvalidHeadersInvalidType := createGRPCRoute(
294307
"gr-1",
295308
gatewayNsName.Name,
296309
"example.com",
297310
[]v1.GRPCRouteRule{headersMatchInvalid},
298311
)
312+
313+
grInvalidHeadersEmptyType := createGRPCRoute(
314+
"gr-1",
315+
gatewayNsName.Name,
316+
"example.com",
317+
[]v1.GRPCRouteRule{headersMatchEmptyType},
318+
)
299319
grOneInvalid := createGRPCRoute(
300320
"gr-1",
301321
gatewayNsName.Name,
@@ -736,6 +756,44 @@ func TestBuildGRPCRoute(t *testing.T) {
736756
},
737757
name: "invalid headers and valid method",
738758
},
759+
{
760+
validator: createAllValidValidator(),
761+
gr: grInvalidHeadersInvalidType,
762+
expected: &L7Route{
763+
Source: grInvalidHeadersInvalidType,
764+
RouteType: RouteTypeGRPC,
765+
Valid: false,
766+
Attachable: true,
767+
ParentRefs: []ParentRef{
768+
{
769+
Idx: 0,
770+
Gateway: gatewayNsName,
771+
SectionName: grInvalidHeadersInvalidType.Spec.ParentRefs[0].SectionName,
772+
},
773+
},
774+
Conditions: []conditions.Condition{
775+
staticConds.NewRouteUnsupportedValue(
776+
`All rules are invalid: spec.rules[0].matches[0].headers[0].type: ` +
777+
`Unsupported value: "": supported values: "Exact"`,
778+
),
779+
},
780+
Spec: L7RouteSpec{
781+
Hostnames: grInvalidHeadersInvalidType.Spec.Hostnames,
782+
Rules: []RouteRule{
783+
{
784+
ValidMatches: false,
785+
Filters: RouteRuleFilters{
786+
Valid: true,
787+
Filters: []Filter{},
788+
},
789+
Matches: convertGRPCMatches(grInvalidHeadersInvalidType.Spec.Rules[0].Matches),
790+
RouteBackendRefs: []RouteBackendRef{},
791+
},
792+
},
793+
},
794+
},
795+
name: "invalid headers with invalid type",
796+
},
739797
{
740798
validator: createAllValidValidator(),
741799
gr: grInvalidHeadersEmptyType,
@@ -754,7 +812,7 @@ func TestBuildGRPCRoute(t *testing.T) {
754812
Conditions: []conditions.Condition{
755813
staticConds.NewRouteUnsupportedValue(
756814
`All rules are invalid: spec.rules[0].matches[0].headers[0].type: ` +
757-
`Unsupported value: "": supported values: "Exact"`,
815+
`Required value: cannot be empty`,
758816
),
759817
},
760818
Spec: L7RouteSpec{
@@ -772,7 +830,7 @@ func TestBuildGRPCRoute(t *testing.T) {
772830
},
773831
},
774832
},
775-
name: "invalid headers with empty type",
833+
name: "invalid headers with no header type specified",
776834
},
777835
{
778836
validator: createAllValidValidator(),

internal/mode/static/state/graph/route_common.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,17 @@ func validateHeaderMatch(
868868
allErrs = append(allErrs, valErr)
869869
}
870870

871+
allErrs = append(allErrs, validateHeaderMatchNameAndValue(validator, headerName, headerValue, headerPath)...)
872+
873+
return allErrs
874+
}
875+
876+
func validateHeaderMatchNameAndValue(
877+
validator validation.HTTPFieldsValidator,
878+
headerName, headerValue string,
879+
headerPath *field.Path,
880+
) field.ErrorList {
881+
var allErrs field.ErrorList
871882
if err := validator.ValidateHeaderNameInMatch(headerName); err != nil {
872883
valErr := field.Invalid(headerPath.Child("name"), headerName, err.Error())
873884
allErrs = append(allErrs, valErr)
@@ -877,7 +888,6 @@ func validateHeaderMatch(
877888
valErr := field.Invalid(headerPath.Child("value"), headerValue, err.Error())
878889
allErrs = append(allErrs, valErr)
879890
}
880-
881891
return allErrs
882892
}
883893

tests/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
k8s.io/apimachinery v0.31.1
1515
k8s.io/client-go v0.31.1
1616
sigs.k8s.io/controller-runtime v0.19.0
17-
sigs.k8s.io/gateway-api v1.1.0
17+
sigs.k8s.io/gateway-api v1.2.0
1818
sigs.k8s.io/yaml v1.4.0
1919
)
2020

@@ -46,7 +46,7 @@ require (
4646
github.com/json-iterator/go v1.1.12 // indirect
4747
github.com/klauspost/compress v1.17.9 // indirect
4848
github.com/mailru/easyjson v0.7.7 // indirect
49-
github.com/miekg/dns v1.1.61 // indirect
49+
github.com/miekg/dns v1.1.62 // indirect
5050
github.com/moby/spdystream v0.4.0 // indirect
5151
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5252
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -72,7 +72,7 @@ require (
7272
golang.org/x/tools v0.25.0 // indirect
7373
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
7474
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
75-
google.golang.org/grpc v1.66.1 // indirect
75+
google.golang.org/grpc v1.66.2 // indirect
7676
google.golang.org/protobuf v1.34.2 // indirect
7777
gopkg.in/inf.v0 v0.9.1 // indirect
7878
gopkg.in/yaml.v2 v2.4.0 // indirect

tests/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
7777
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
7878
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
7979
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
80-
github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs=
81-
github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ=
80+
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
81+
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
8282
github.com/moby/spdystream v0.4.0 h1:Vy79D6mHeJJjiPdFEL2yku1kl0chZpJfZcPpb16BRl8=
8383
github.com/moby/spdystream v0.4.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
8484
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -187,8 +187,8 @@ gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJ
187187
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
188188
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
189189
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
190-
google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM=
191-
google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
190+
google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo=
191+
google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
192192
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
193193
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
194194
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -221,8 +221,8 @@ pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
221221
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
222222
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
223223
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
224-
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
225-
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
224+
sigs.k8s.io/gateway-api v1.2.0 h1:LrToiFwtqKTKZcZtoQPTuo3FxhrrhTgzQG0Te+YGSo8=
225+
sigs.k8s.io/gateway-api v1.2.0/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0=
226226
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
227227
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
228228
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

0 commit comments

Comments
 (0)