Skip to content

Commit 334ea35

Browse files
authored
chore: bump gateway API to 1.0.0-rc1 (#4893)
* chore: bump gateway API to 1.0.0-rc1 * add type meta and update golden tests * fix annotation of gateway * replace gatewayv1beta1 with gatewayv1 if possible and skip failing conformance tests * add gatewayv1beta1 GVR for validation * add changelog entry
1 parent 7368717 commit 334ea35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+429
-379
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Adding a new version? You'll need three changes:
149149

150150
- Update paths of Konnect APIs from `runtime_groups/*` to `control-planes/*`.
151151
[#4566](https://github.com/Kong/kubernetes-ingress-controller/pull/4566)
152+
- Bump version of gateway API to `1.0.0-rc1` and support `Gateway`, `GatewayClass`
153+
and `HTTPRoute` in API version `gateway.networking.k8s.io/v1`.
154+
[#4893](https://github.com/Kong/kubernetes-ingress-controller/pull/4893)
152155

153156
### Added
154157

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require (
5656
k8s.io/client-go v0.28.3
5757
k8s.io/component-base v0.28.2
5858
sigs.k8s.io/controller-runtime v0.16.2
59-
sigs.k8s.io/gateway-api v0.8.1
59+
sigs.k8s.io/gateway-api v1.0.0-rc1
6060
sigs.k8s.io/kustomize/api v0.14.0
6161
sigs.k8s.io/kustomize/kyaml v0.14.3
6262
sigs.k8s.io/yaml v1.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,8 @@ k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSn
687687
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
688688
sigs.k8s.io/controller-runtime v0.16.2 h1:mwXAVuEk3EQf478PQwQ48zGOXvW27UJc8NHktQVuIPU=
689689
sigs.k8s.io/controller-runtime v0.16.2/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU=
690-
sigs.k8s.io/gateway-api v0.8.1 h1:Bo4NMAQFYkQZnHXOfufbYwbPW7b3Ic5NjpbeW6EJxuU=
691-
sigs.k8s.io/gateway-api v0.8.1/go.mod h1:0PteDrsrgkRmr13nDqFWnev8tOysAVrwnvfFM55tSVg=
690+
sigs.k8s.io/gateway-api v1.0.0-rc1 h1:v7N9fWTcQxox5aP2IrViDw6imeUHMAt2WFjI4BYo0sw=
691+
sigs.k8s.io/gateway-api v1.0.0-rc1/go.mod h1:+QpYENjk9s31/abu2Pv5BpK2v88UQDK2aeQCwCvy6ck=
692692
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
693693
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
694694
sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8=

internal/admission/handler.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
corev1 "k8s.io/api/core/v1"
1212
netv1 "k8s.io/api/networking/v1"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
1514

1615
"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
1716
"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
@@ -91,16 +90,6 @@ var (
9190
Version: corev1.SchemeGroupVersion.Version,
9291
Resource: "secrets",
9392
}
94-
gatewayGVResource = metav1.GroupVersionResource{
95-
Group: gatewayv1beta1.GroupVersion.Group,
96-
Version: gatewayv1beta1.GroupVersion.Version,
97-
Resource: "gateways",
98-
}
99-
httprouteGVResource = metav1.GroupVersionResource{
100-
Group: gatewayv1beta1.GroupVersion.Group,
101-
Version: gatewayv1beta1.GroupVersion.Version,
102-
Resource: "httproutes",
103-
}
10493
ingressGVResource = metav1.GroupVersionResource{
10594
Group: netv1.SchemeGroupVersion.Group,
10695
Version: netv1.SchemeGroupVersion.Version,
@@ -124,9 +113,9 @@ func (h RequestHandler) handleValidation(ctx context.Context, request admissionv
124113
return h.handleKongClusterPlugin(ctx, request, responseBuilder)
125114
case secretGVResource:
126115
return h.handleSecret(ctx, request, responseBuilder)
127-
case gatewayGVResource:
116+
case gatewayapi.V1GatewayGVResource, gatewayapi.V1beta1GatewayGVResource:
128117
return h.handleGateway(ctx, request, responseBuilder)
129-
case httprouteGVResource:
118+
case gatewayapi.V1HTTPRouteGVResource, gatewayapi.V1beta1HTTPRouteGVResource:
130119
return h.handleHTTPRoute(ctx, request, responseBuilder)
131120
case kongIngressGVResource:
132121
return h.handleKongIngress(ctx, request, responseBuilder)

internal/controllers/gateway/gateway_controller.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"sigs.k8s.io/controller-runtime/pkg/predicate"
2323
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2424
"sigs.k8s.io/controller-runtime/pkg/source"
25+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2526
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
2627

2728
"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
@@ -36,7 +37,7 @@ import (
3637
// Vars & Consts
3738
// -----------------------------------------------------------------------------
3839

39-
var gatewayV1beta1Group = gatewayapi.Group(gatewayv1beta1.GroupName)
40+
var gatewayV1Group = gatewayapi.Group(gatewayv1.GroupName)
4041

4142
// -----------------------------------------------------------------------------
4243
// Gateway Controller - GatewayReconciler
@@ -329,7 +330,7 @@ func referenceGrantHasGatewayFrom(obj client.Object) bool {
329330
// Reconcile is part of the main kubernetes reconciliation loop which aims to
330331
// move the current state of the cluster closer to the desired state.
331332
func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
332-
log := r.Log.WithValues("GatewayV1Beta1Gateway", req.NamespacedName)
333+
log := r.Log.WithValues("GatewayV1Gateway", req.NamespacedName)
333334

334335
// gather the gateway object based on the reconciliation trigger. It's possible for the object
335336
// to be gone at this point in which case it will be ignored.
@@ -646,8 +647,8 @@ func (r *GatewayReconciler) determineL4ListenersFromService(
646647
addresses := make([]gatewayapi.GatewayAddress, 0, len(svc.Spec.ClusterIPs))
647648
listeners := make([]gatewayapi.Listener, 0, len(svc.Spec.Ports))
648649
protocolToRouteGroupKind := map[corev1.Protocol]gatewayapi.RouteGroupKind{
649-
corev1.ProtocolTCP: {Group: &gatewayV1beta1Group, Kind: gatewayapi.Kind("TCPRoute")},
650-
corev1.ProtocolUDP: {Group: &gatewayV1beta1Group, Kind: gatewayapi.Kind("UDPRoute")},
650+
corev1.ProtocolTCP: {Group: &gatewayV1Group, Kind: gatewayapi.Kind("TCPRoute")},
651+
corev1.ProtocolUDP: {Group: &gatewayV1Group, Kind: gatewayapi.Kind("UDPRoute")},
651652
}
652653

653654
for _, port := range svc.Spec.Ports {
@@ -742,7 +743,7 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
742743
listener.Protocol = gatewayapi.TLSProtocolType
743744
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
744745
Kinds: []gatewayapi.RouteGroupKind{
745-
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
746+
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
746747
},
747748
}
748749
}
@@ -752,14 +753,14 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
752753
listener.Protocol = gatewayapi.HTTPSProtocolType
753754
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
754755
Kinds: []gatewayapi.RouteGroupKind{
755-
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
756+
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
756757
},
757758
}
758759
} else {
759760
listener.Protocol = gatewayapi.HTTPProtocolType
760761
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
761762
Kinds: []gatewayapi.RouteGroupKind{
762-
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
763+
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
763764
},
764765
}
765766
}

internal/controllers/gateway/gateway_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
418418
Spec: gatewayapi.ReferenceGrantSpec{
419419
From: []gatewayapi.ReferenceGrantFrom{
420420
{
421-
Group: gatewayV1beta1Group,
421+
Group: gatewayV1Group,
422422
Kind: "Gateway",
423423
Namespace: "test",
424424
},
@@ -468,7 +468,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
468468
},
469469
// good entry
470470
{
471-
Group: gatewayV1beta1Group,
471+
Group: gatewayV1Group,
472472
Kind: "Gateway",
473473
Namespace: "test",
474474
},
@@ -500,7 +500,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
500500
Spec: gatewayapi.ReferenceGrantSpec{
501501
From: []gatewayapi.ReferenceGrantFrom{
502502
{
503-
Group: gatewayV1beta1Group,
503+
Group: gatewayV1Group,
504504
Kind: "Gateway",
505505
Namespace: "test",
506506
},

internal/controllers/gateway/gateway_utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/client"
1717
"sigs.k8s.io/controller-runtime/pkg/event"
1818
"sigs.k8s.io/controller-runtime/pkg/reconcile"
19-
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
19+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2020

2121
"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
2222
"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
@@ -530,7 +530,7 @@ func getReferenceGrantConditionReason(
530530
}
531531
for _, from := range grant.Spec.From {
532532
// we are interested only in grants for gateways that want to reference secrets
533-
if from.Group != gatewayV1beta1Group || from.Kind != "Gateway" {
533+
if from.Group != gatewayV1Group || from.Kind != "Gateway" {
534534
continue
535535
}
536536
if from.Namespace == gatewayapi.Namespace(gatewayNamespace) {
@@ -617,7 +617,7 @@ func getListenerSupportedRouteKinds(l gatewayapi.Listener) ([]gatewayapi.RouteGr
617617
reason = gatewayapi.ListenerReasonResolvedRefs
618618
)
619619
for _, gk := range l.AllowedRoutes.Kinds {
620-
if gk.Group != nil && *gk.Group == gatewayv1beta1.GroupName {
620+
if gk.Group != nil && *gk.Group == gatewayv1.GroupName {
621621
_, ok := lo.Find(supportedKinds, func(k gatewayapi.Kind) bool {
622622
return gk.Kind == k
623623
})
@@ -659,7 +659,7 @@ func routeAcceptedByGateways(routeNamespace string, parentStatuses []gatewayapi.
659659
for _, routeParentStatus := range parentStatuses {
660660
gatewayNamespace := routeNamespace
661661
parentRef := routeParentStatus.ParentRef
662-
if (parentRef.Group != nil && *parentRef.Group != gatewayV1beta1Group) ||
662+
if (parentRef.Group != nil && *parentRef.Group != gatewayV1Group) ||
663663
(parentRef.Kind != nil && *parentRef.Kind != "Gateway") {
664664
continue
665665
}

internal/controllers/gateway/gateway_utils_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
k8stypes "k8s.io/apimachinery/pkg/types"
1212
"k8s.io/client-go/kubernetes/scheme"
1313
"sigs.k8s.io/controller-runtime/pkg/client/fake"
14-
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
14+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
1515

1616
"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
1717
"github.com/kong/kubernetes-ingress-controller/v2/internal/util/builder"
1818
)
1919

2020
func init() {
21-
if err := gatewayv1beta1.Install(scheme.Scheme); err != nil {
21+
if err := gatewayv1.Install(scheme.Scheme); err != nil {
2222
panic(err)
2323
}
2424
}
@@ -84,15 +84,15 @@ func TestGetListenerSupportedRouteKinds(t *testing.T) {
8484
Kind: gatewayapi.Kind("UnknownKind"),
8585
},
8686
{
87-
Group: &gatewayV1beta1Group,
87+
Group: &gatewayV1Group,
8888
Kind: gatewayapi.Kind("HTTPRoute"),
8989
},
9090
},
9191
},
9292
},
9393
expectedSupportedKinds: []gatewayapi.RouteGroupKind{
9494
{
95-
Group: &gatewayV1beta1Group,
95+
Group: &gatewayV1Group,
9696
Kind: gatewayapi.Kind("HTTPRoute"),
9797
},
9898
},

internal/controllers/gateway/gatewayclass_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (r *GatewayClassReconciler) GatewayClassIsUnmanaged(obj client.Object) bool
110110
// Reconcile is part of the main kubernetes reconciliation loop which aims to
111111
// move the current state of the cluster closer to the desired state.
112112
func (r *GatewayClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
113-
log := r.Log.WithValues("GatewayV1Beta1GatewayClass", req.NamespacedName)
113+
log := r.Log.WithValues("GatewayV1GatewayClass", req.NamespacedName)
114114

115115
gwc := new(gatewayapi.GatewayClass)
116116
if err := r.Client.Get(ctx, req.NamespacedName, gwc); err != nil {

internal/controllers/gateway/httproute_controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"sigs.k8s.io/controller-runtime/pkg/predicate"
2323
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2424
"sigs.k8s.io/controller-runtime/pkg/source"
25+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2526
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
2627

2728
"github.com/kong/kubernetes-ingress-controller/v2/internal/controllers"
@@ -118,8 +119,8 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error {
118119
if r.StatusQueue != nil {
119120
if err := c.Watch(
120121
&source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{
121-
Group: gatewayv1beta1.GroupVersion.Group,
122-
Version: gatewayv1beta1.GroupVersion.Version,
122+
Group: gatewayv1.GroupVersion.Group,
123+
Version: gatewayv1.GroupVersion.Version,
123124
Kind: "HTTPRoute",
124125
})},
125126
&handler.EnqueueRequestForObject{},
@@ -330,7 +331,7 @@ func (r *HTTPRouteReconciler) listHTTPRoutesForGateway(ctx context.Context, obj
330331
// Reconcile is part of the main kubernetes reconciliation loop which aims to
331332
// move the current state of the cluster closer to the desired state.
332333
func (r *HTTPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
333-
log := r.Log.WithValues("GatewayV1Beta1HTTPRoute", req.NamespacedName)
334+
log := r.Log.WithValues("GatewayV1HTTPRoute", req.NamespacedName)
334335

335336
httproute := new(gatewayapi.HTTPRoute)
336337
if err := r.Get(ctx, req.NamespacedName, httproute); err != nil {
@@ -518,7 +519,7 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont
518519
// build a new status for the parent Gateway
519520
gatewayParentStatus := &gatewayapi.RouteParentStatus{
520521
ParentRef: gatewayapi.ParentReference{
521-
Group: (*gatewayapi.Group)(&gatewayv1beta1.GroupVersion.Group),
522+
Group: (*gatewayapi.Group)(&gatewayv1.GroupVersion.Group),
522523
Kind: util.StringToGatewayAPIKindPtr(httprouteParentKind),
523524
Namespace: (*gatewayapi.Namespace)(&gateway.gateway.Namespace),
524525
Name: gatewayapi.ObjectName(gateway.gateway.Name),

0 commit comments

Comments
 (0)