Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump gateway API to 1.0.0-rc1 #4893

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ Adding a new version? You'll need three changes:

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

### Added

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
k8s.io/client-go v0.28.3
k8s.io/component-base v0.28.2
sigs.k8s.io/controller-runtime v0.16.2
sigs.k8s.io/gateway-api v0.8.1
sigs.k8s.io/gateway-api v1.0.0-rc1
sigs.k8s.io/kustomize/api v0.14.0
sigs.k8s.io/kustomize/kyaml v0.14.3
sigs.k8s.io/yaml v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSn
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.16.2 h1:mwXAVuEk3EQf478PQwQ48zGOXvW27UJc8NHktQVuIPU=
sigs.k8s.io/controller-runtime v0.16.2/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU=
sigs.k8s.io/gateway-api v0.8.1 h1:Bo4NMAQFYkQZnHXOfufbYwbPW7b3Ic5NjpbeW6EJxuU=
sigs.k8s.io/gateway-api v0.8.1/go.mod h1:0PteDrsrgkRmr13nDqFWnev8tOysAVrwnvfFM55tSVg=
sigs.k8s.io/gateway-api v1.0.0-rc1 h1:v7N9fWTcQxox5aP2IrViDw6imeUHMAt2WFjI4BYo0sw=
sigs.k8s.io/gateway-api v1.0.0-rc1/go.mod h1:+QpYENjk9s31/abu2Pv5BpK2v88UQDK2aeQCwCvy6ck=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8=
Expand Down
15 changes: 2 additions & 13 deletions internal/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
Expand Down Expand Up @@ -91,16 +90,6 @@ var (
Version: corev1.SchemeGroupVersion.Version,
Resource: "secrets",
}
gatewayGVResource = metav1.GroupVersionResource{
Group: gatewayv1beta1.GroupVersion.Group,
Version: gatewayv1beta1.GroupVersion.Version,
Resource: "gateways",
}
httprouteGVResource = metav1.GroupVersionResource{
Group: gatewayv1beta1.GroupVersion.Group,
Version: gatewayv1beta1.GroupVersion.Version,
Resource: "httproutes",
}
ingressGVResource = metav1.GroupVersionResource{
Group: netv1.SchemeGroupVersion.Group,
Version: netv1.SchemeGroupVersion.Version,
Expand All @@ -124,9 +113,9 @@ func (h RequestHandler) handleValidation(ctx context.Context, request admissionv
return h.handleKongClusterPlugin(ctx, request, responseBuilder)
case secretGVResource:
return h.handleSecret(ctx, request, responseBuilder)
case gatewayGVResource:
case gatewayapi.V1GatewayGVResource, gatewayapi.V1beta1GatewayGVResource:
return h.handleGateway(ctx, request, responseBuilder)
case httprouteGVResource:
case gatewayapi.V1HTTPRouteGVResource, gatewayapi.V1beta1HTTPRouteGVResource:
return h.handleHTTPRoute(ctx, request, responseBuilder)
case kongIngressGVResource:
return h.handleKongIngress(ctx, request, responseBuilder)
Expand Down
15 changes: 8 additions & 7 deletions internal/controllers/gateway/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

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

var gatewayV1beta1Group = gatewayapi.Group(gatewayv1beta1.GroupName)
var gatewayV1Group = gatewayapi.Group(gatewayv1.GroupName)

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

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

for _, port := range svc.Spec.Ports {
Expand Down Expand Up @@ -742,7 +743,7 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
listener.Protocol = gatewayapi.TLSProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("TLSRoute")},
},
}
}
Expand All @@ -752,14 +753,14 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(
listener.Protocol = gatewayapi.HTTPSProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
},
}
} else {
listener.Protocol = gatewayapi.HTTPProtocolType
listener.AllowedRoutes = &gatewayapi.AllowedRoutes{
Kinds: []gatewayapi.RouteGroupKind{
{Group: &gatewayV1beta1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
{Group: &gatewayV1Group, Kind: (gatewayapi.Kind)("HTTPRoute")},
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/gateway/gateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
Spec: gatewayapi.ReferenceGrantSpec{
From: []gatewayapi.ReferenceGrantFrom{
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down Expand Up @@ -468,7 +468,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
},
// good entry
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestGetReferenceGrantConditionReason(t *testing.T) {
Spec: gatewayapi.ReferenceGrantSpec{
From: []gatewayapi.ReferenceGrantFrom{
{
Group: gatewayV1beta1Group,
Group: gatewayV1Group,
Kind: "Gateway",
Namespace: "test",
},
Expand Down
8 changes: 4 additions & 4 deletions internal/controllers/gateway/gateway_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
Expand Down Expand Up @@ -530,7 +530,7 @@ func getReferenceGrantConditionReason(
}
for _, from := range grant.Spec.From {
// we are interested only in grants for gateways that want to reference secrets
if from.Group != gatewayV1beta1Group || from.Kind != "Gateway" {
if from.Group != gatewayV1Group || from.Kind != "Gateway" {
continue
}
if from.Namespace == gatewayapi.Namespace(gatewayNamespace) {
Expand Down Expand Up @@ -617,7 +617,7 @@ func getListenerSupportedRouteKinds(l gatewayapi.Listener) ([]gatewayapi.RouteGr
reason = gatewayapi.ListenerReasonResolvedRefs
)
for _, gk := range l.AllowedRoutes.Kinds {
if gk.Group != nil && *gk.Group == gatewayv1beta1.GroupName {
if gk.Group != nil && *gk.Group == gatewayv1.GroupName {
_, ok := lo.Find(supportedKinds, func(k gatewayapi.Kind) bool {
return gk.Kind == k
})
Expand Down Expand Up @@ -659,7 +659,7 @@ func routeAcceptedByGateways(routeNamespace string, parentStatuses []gatewayapi.
for _, routeParentStatus := range parentStatuses {
gatewayNamespace := routeNamespace
parentRef := routeParentStatus.ParentRef
if (parentRef.Group != nil && *parentRef.Group != gatewayV1beta1Group) ||
if (parentRef.Group != nil && *parentRef.Group != gatewayV1Group) ||
(parentRef.Kind != nil && *parentRef.Kind != "Gateway") {
continue
}
Expand Down
8 changes: 4 additions & 4 deletions internal/controllers/gateway/gateway_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

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

func init() {
if err := gatewayv1beta1.Install(scheme.Scheme); err != nil {
if err := gatewayv1.Install(scheme.Scheme); err != nil {
panic(err)
}
}
Expand Down Expand Up @@ -84,15 +84,15 @@ func TestGetListenerSupportedRouteKinds(t *testing.T) {
Kind: gatewayapi.Kind("UnknownKind"),
},
{
Group: &gatewayV1beta1Group,
Group: &gatewayV1Group,
Kind: gatewayapi.Kind("HTTPRoute"),
},
},
},
},
expectedSupportedKinds: []gatewayapi.RouteGroupKind{
{
Group: &gatewayV1beta1Group,
Group: &gatewayV1Group,
Kind: gatewayapi.Kind("HTTPRoute"),
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/gateway/gatewayclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (r *GatewayClassReconciler) GatewayClassIsUnmanaged(obj client.Object) bool
// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *GatewayClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("GatewayV1Beta1GatewayClass", req.NamespacedName)
log := r.Log.WithValues("GatewayV1GatewayClass", req.NamespacedName)

gwc := new(gatewayapi.GatewayClass)
if err := r.Client.Get(ctx, req.NamespacedName, gwc); err != nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/controllers/gateway/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

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

httproute := new(gatewayapi.HTTPRoute)
if err := r.Get(ctx, req.NamespacedName, httproute); err != nil {
Expand Down Expand Up @@ -518,7 +519,7 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont
// build a new status for the parent Gateway
gatewayParentStatus := &gatewayapi.RouteParentStatus{
ParentRef: gatewayapi.ParentReference{
Group: (*gatewayapi.Group)(&gatewayv1beta1.GroupVersion.Group),
Group: (*gatewayapi.Group)(&gatewayv1.GroupVersion.Group),
Kind: util.StringToGatewayAPIKindPtr(httprouteParentKind),
Namespace: (*gatewayapi.Namespace)(&gateway.gateway.Namespace),
Name: gatewayapi.ObjectName(gateway.gateway.Name),
Expand Down
12 changes: 6 additions & 6 deletions internal/controllers/gateway/route_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/kong/kubernetes-ingress-controller/v2/internal/gatewayapi"
"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
Expand Down Expand Up @@ -481,8 +481,8 @@ func existsMatchingReadyListenerInStatus[T gatewayapi.RouteT](route T, listener
switch any(route).(type) {
case *gatewayapi.HTTPRoute:
gvk = schema.GroupVersionKind{
Group: gatewayv1beta1.GroupVersion.Group,
Version: gatewayv1beta1.GroupVersion.Version,
Group: gatewayv1.GroupVersion.Group,
Version: gatewayv1.GroupVersion.Version,
Kind: "HTTPRoute",
}
default:
Expand Down Expand Up @@ -656,7 +656,7 @@ func isHTTPReferenceGranted(grantSpec gatewayapi.ReferenceGrantSpec, backendRef
backendRefKind = *backendRef.Kind
}
for _, from := range grantSpec.From {
if from.Group != gatewayv1beta1.GroupName || from.Kind != "HTTPRoute" || fromNamespace != string(from.Namespace) {
if from.Group != gatewayv1.GroupName || from.Kind != "HTTPRoute" || fromNamespace != string(from.Namespace) {
continue
}

Expand Down Expand Up @@ -753,7 +753,7 @@ func ensureParentsProgrammedCondition[
Namespace: lo.ToPtr(gatewayapi.Namespace(gateway.Namespace)),
Name: gatewayapi.ObjectName(gateway.Name),
Kind: lo.ToPtr(gatewayapi.Kind("Gateway")),
Group: lo.ToPtr(gatewayapi.Group(gatewayv1beta1.GroupName)),
Group: lo.ToPtr(gatewayapi.Group(gatewayv1.GroupName)),
SectionName: func() *gatewayapi.SectionName {
// We don't need to check whether the listener matches route's spec
// because that should already be done via getSupportedGatewayForRoute
Expand Down Expand Up @@ -865,7 +865,7 @@ func isParentRefEqualToParent[
parentRef gatewayapi.ParentReference,
parent parentT,
) bool {
if *parentRef.Group != gatewayv1beta1.GroupName {
if *parentRef.Group != gatewayv1.GroupName {
return false
}
if *parentRef.Kind != "Gateway" {
Expand Down
Loading