diff --git a/internal/admission/server.go b/internal/admission/server.go index 77200057b7..da57bcc37f 100644 --- a/internal/admission/server.go +++ b/internal/admission/server.go @@ -16,7 +16,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" "sigs.k8s.io/controller-runtime/pkg/certwatcher" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" configuration "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1" @@ -184,13 +183,13 @@ var ( Resource: "secrets", } gatewayGVResource = metav1.GroupVersionResource{ - Group: gatewayv1alpha2.SchemeGroupVersion.Group, - Version: gatewayv1alpha2.SchemeGroupVersion.Version, + Group: gatewayv1beta1.SchemeGroupVersion.Group, + Version: gatewayv1beta1.SchemeGroupVersion.Version, Resource: "gateways", } httprouteGVResource = metav1.GroupVersionResource{ - Group: gatewayv1alpha2.SchemeGroupVersion.Group, - Version: gatewayv1alpha2.SchemeGroupVersion.Version, + Group: gatewayv1beta1.SchemeGroupVersion.Group, + Version: gatewayv1beta1.SchemeGroupVersion.Version, Resource: "httproutes", } ) @@ -294,7 +293,7 @@ func (a RequestHandler) handleValidation(ctx context.Context, request admissionv return nil, fmt.Errorf("unknown operation '%v'", string(request.Operation)) } case gatewayGVResource: - gateway := gatewayv1alpha2.Gateway{} + gateway := gatewayv1beta1.Gateway{} deserializer := codecs.UniversalDeserializer() _, _, err = deserializer.Decode(request.Object.Raw, nil, &gateway) if err != nil { diff --git a/internal/admission/server_test.go b/internal/admission/server_test.go index 344f02df65..afc0f5b190 100644 --- a/internal/admission/server_test.go +++ b/internal/admission/server_test.go @@ -15,7 +15,6 @@ import ( admissionv1 "k8s.io/api/admission/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" configuration "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1" @@ -51,7 +50,7 @@ func (v KongFakeValidator) ValidateCredential(ctx context.Context, secret corev1 return v.Result, v.Message, v.Error } -func (v KongFakeValidator) ValidateGateway(ctx context.Context, gateway gatewayv1alpha2.Gateway) (bool, string, error) { +func (v KongFakeValidator) ValidateGateway(ctx context.Context, gateway gatewayv1beta1.Gateway) (bool, string, error) { return v.Result, v.Message, v.Error } diff --git a/internal/admission/validator.go b/internal/admission/validator.go index 394f3cf3b1..6baaed8090 100644 --- a/internal/admission/validator.go +++ b/internal/admission/validator.go @@ -11,8 +11,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" gatewaycontroller "github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/gateway" @@ -28,8 +26,8 @@ type KongValidator interface { ValidatePlugin(ctx context.Context, plugin kongv1.KongPlugin) (bool, string, error) ValidateClusterPlugin(ctx context.Context, plugin kongv1.KongClusterPlugin) (bool, string, error) ValidateCredential(ctx context.Context, secret corev1.Secret) (bool, string, error) - ValidateGateway(ctx context.Context, gateway gatewayv1alpha2.Gateway) (bool, string, error) - ValidateHTTPRoute(ctx context.Context, httproute gatewayv1beta1.HTTPRoute) (bool, string, error) + ValidateGateway(ctx context.Context, gateway gatewaycontroller.Gateway) (bool, string, error) + ValidateHTTPRoute(ctx context.Context, httproute gatewaycontroller.HTTPRoute) (bool, string, error) } // KongHTTPValidator implements KongValidator interface to validate Kong @@ -298,7 +296,7 @@ func (validator KongHTTPValidator) ValidateClusterPlugin( } func (validator KongHTTPValidator) ValidateGateway( - ctx context.Context, gateway gatewayv1alpha2.Gateway, + ctx context.Context, gateway gatewaycontroller.Gateway, ) (bool, string, error) { // check if the gateway declares a gateway class if gateway.Spec.GatewayClassName == "" { @@ -306,7 +304,7 @@ func (validator KongHTTPValidator) ValidateGateway( } // validate the gatewayclass reference - gwc := gatewayv1beta1.GatewayClass{} + gwc := gatewaycontroller.GatewayClass{} if err := validator.ManagerClient.Get(ctx, client.ObjectKey{Name: string(gateway.Spec.GatewayClassName)}, &gwc); err != nil { if strings.Contains(err.Error(), "not found") { return true, "", nil // not managed by this controller @@ -316,7 +314,7 @@ func (validator KongHTTPValidator) ValidateGateway( // validate whether the gatewayclass is a supported class, if not // then this gateway belongs to another controller. - if string(gwc.Spec.ControllerName) != string(gatewaycontroller.ControllerName) { + if gwc.Spec.ControllerName != gatewaycontroller.ControllerName { return true, "", nil } @@ -324,11 +322,11 @@ func (validator KongHTTPValidator) ValidateGateway( } func (validator KongHTTPValidator) ValidateHTTPRoute( - ctx context.Context, httproute gatewayv1beta1.HTTPRoute, + ctx context.Context, httproute gatewaycontroller.HTTPRoute, ) (bool, string, error) { // in order to be sure whether or not an HTTPRoute resource is managed by this // controller we disallow references to Gateway resources that do not exist. - var managedGateways []*gatewayv1alpha2.Gateway + var managedGateways []*gatewaycontroller.Gateway for _, parentRef := range httproute.Spec.ParentRefs { // determine the namespace of the gateway referenced via parentRef. If no // explicit namespace is provided, assume the namespace of the route. @@ -339,7 +337,7 @@ func (validator KongHTTPValidator) ValidateHTTPRoute( // gather the Gateway resource referenced by parentRef and fail validation // if there is no such Gateway resource. - gateway := gatewayv1alpha2.Gateway{} + gateway := gatewaycontroller.Gateway{} if err := validator.ManagerClient.Get(ctx, client.ObjectKey{ Namespace: namespace, Name: string(parentRef.Name), @@ -348,7 +346,7 @@ func (validator KongHTTPValidator) ValidateHTTPRoute( } // pull the referenced GatewayClass object from the Gateway - gatewayClass := gatewayv1beta1.GatewayClass{} + gatewayClass := gatewaycontroller.GatewayClass{} if err := validator.ManagerClient.Get(ctx, client.ObjectKey{Name: string(gateway.Spec.GatewayClassName)}, &gatewayClass); err != nil { return false, fmt.Sprintf("couldn't retrieve referenced gatewayclass %s", gateway.Spec.GatewayClassName), err } diff --git a/internal/controllers/gateway/gateway_controller.go b/internal/controllers/gateway/gateway_controller.go index e06c3aba24..55461b5e35 100644 --- a/internal/controllers/gateway/gateway_controller.go +++ b/internal/controllers/gateway/gateway_controller.go @@ -34,7 +34,7 @@ var ( // ErrManagedGatewaysUnsupported is an error used whenever a failure occurs // due to a Gateway that is not properly configured for unmanaged mode. ErrManagedGatewaysUnsupported = fmt.Errorf("invalid gateway spec: managed gateways are not currently supported") - gatewayV1alpha2Group = gatewayv1alpha2.Group(gatewayv1alpha2.GroupName) + gatewayV1beta1Group = gatewayv1beta1.Group(gatewayv1beta1.GroupName) ) // ----------------------------------------------------------------------------- @@ -81,7 +81,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { // watch Gateway objects, filtering out any Gateways which are not configured with // a supported GatewayClass controller name. if err := c.Watch( - &source.Kind{Type: &gatewayv1alpha2.Gateway{}}, + &source.Kind{Type: &gatewayv1beta1.Gateway{}}, &handler.EnqueueRequestForObject{}, predicate.NewPredicateFuncs(r.gatewayHasMatchingGatewayClass), ); err != nil { @@ -137,9 +137,9 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { // gatewayHasMatchingGatewayClass is a watch predicate which filters out reconciliation events for // gateway objects which aren't supported by this controller. func (r *GatewayReconciler) gatewayHasMatchingGatewayClass(obj client.Object) bool { - gateway, ok := obj.(*gatewayv1alpha2.Gateway) + gateway, ok := obj.(*gatewayv1beta1.Gateway) if !ok { - r.Log.Error(fmt.Errorf("unexpected object type in gateway watch predicates"), "expected", "*gatewayv1alpha2.Gateway", "found", reflect.TypeOf(obj)) + r.Log.Error(fmt.Errorf("unexpected object type in gateway watch predicates"), "expected", "*gatewayv1beta1.Gateway", "found", reflect.TypeOf(obj)) return false } gatewayClass := &gatewayv1beta1.GatewayClass{} @@ -165,7 +165,7 @@ func (r *GatewayReconciler) gatewayClassMatchesController(obj client.Object) boo // by a gatewayclass to enqueue them for reconciliation. This is generally used when a GatewayClass // is updated to ensure that idle gateways are initialized when their gatewayclass becomes available. func (r *GatewayReconciler) listGatewaysForGatewayClass(gatewayClass client.Object) []reconcile.Request { - gateways := &gatewayv1alpha2.GatewayList{} + gateways := &gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), gateways); err != nil { r.Log.Error(err, "failed to list gateways for gatewayclass in watch", "gatewayclass", gatewayClass.GetName()) return nil @@ -182,7 +182,7 @@ func (r *GatewayReconciler) listReferenceGrantsForGateway(obj client.Object) []r "*gatewayv1alpha2.ReferenceGrant", "found", reflect.TypeOf(obj)) return nil } - gateways := &gatewayv1alpha2.GatewayList{} + gateways := &gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), gateways); err != nil { r.Log.Error(err, "failed to list gateways in watch", "referencegrant", grant.Name) return nil @@ -210,7 +210,7 @@ func (r *GatewayReconciler) listReferenceGrantsForGateway(obj client.Object) []r // unmanaged mode and enqueues them for reconciliation. This is generally used to ensure // all gateways are updated when the service gets updated with new listeners. func (r *GatewayReconciler) listGatewaysForService(svc client.Object) (recs []reconcile.Request) { - gateways := &gatewayv1alpha2.GatewayList{} + gateways := &gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), gateways); err != nil { r.Log.Error(err, "failed to list gateways for service in watch predicates", "service") return @@ -245,7 +245,7 @@ func referenceGrantHasGatewayFrom(obj client.Object) bool { return false } for _, from := range grant.Spec.From { - if from.Kind == gatewayv1alpha2.Kind("Gateway") && from.Group == gatewayv1alpha2.Group("gateway.networking.k8s.io") { + if from.Kind == "Gateway" && from.Group == "gateway.networking.k8s.io" { return true } } @@ -262,11 +262,11 @@ 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("V1Alpha2Gateway", req.NamespacedName) + log := r.Log.WithValues("V1Beta1Gateway", 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. - gateway := new(gatewayv1alpha2.Gateway) + gateway := new(gatewayv1beta1.Gateway) if err := r.Get(ctx, req.NamespacedName, gateway); err != nil { if errors.IsNotFound(err) { debug(log, gateway, "reconciliation triggered but gateway does not exist, ignoring") @@ -327,7 +327,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct // reconcileUnmanagedGateway reconciles a Gateway that is configured for unmanaged mode, // this mode will extract the Addresses and Listeners for the Gateway from the Kubernetes Service // used for the Kong Gateway in the pre-existing deployment. -func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log logr.Logger, gateway *gatewayv1alpha2.Gateway) (ctrl.Result, error) { +func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log logr.Logger, gateway *gatewayv1beta1.Gateway) (ctrl.Result, error) { // currently this controller supports only unmanaged gateway mode, we need to verify // any Gateway object that comes to us is configured appropriately, and if not reject it // with a clear status condition and message. @@ -362,11 +362,11 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l info(log, gateway, "marking gateway as scheduled") if !isGatewayScheduled(gateway) { scheduledCondition := metav1.Condition{ - Type: string(gatewayv1alpha2.GatewayConditionScheduled), + Type: string(gatewayv1beta1.GatewayConditionScheduled), Status: metav1.ConditionTrue, ObservedGeneration: gateway.Generation, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.GatewayReasonScheduled), + Reason: string(gatewayv1beta1.GatewayReasonScheduled), Message: "this unmanaged gateway has been picked up by the controller and will be processed", } setGatewayCondition(gateway, scheduledCondition) @@ -448,19 +448,19 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l var ( // supportedKinds indicates which gateway kinds are supported by this implementation. - supportedKinds = []gatewayv1alpha2.Kind{ - gatewayv1alpha2.Kind("HTTPRoute"), + supportedKinds = []Kind{ + Kind("HTTPRoute"), } // supportedRouteGroupKinds indicates the full kinds with GVK that are supported by this implementation. - supportedRouteGroupKinds []gatewayv1alpha2.RouteGroupKind + supportedRouteGroupKinds []gatewayv1beta1.RouteGroupKind ) func init() { // gather the supported RouteGroupKinds for the Gateway listeners - group := gatewayv1alpha2.Group(gatewayv1alpha2.GroupName) + group := gatewayv1beta1.Group(gatewayv1beta1.GroupName) for _, supportedKind := range supportedKinds { - supportedRouteGroupKinds = append(supportedRouteGroupKinds, gatewayv1alpha2.RouteGroupKind{ + supportedRouteGroupKinds = append(supportedRouteGroupKinds, gatewayv1beta1.RouteGroupKind{ Group: &group, Kind: supportedKind, }) @@ -488,8 +488,8 @@ func (r *GatewayReconciler) determineL4ListenersFromService( log logr.Logger, svc *corev1.Service, ) ( - []gatewayv1alpha2.GatewayAddress, - []gatewayv1alpha2.Listener, + []GatewayAddress, + []Listener, error, ) { // if there are no clusterIPs available yet then this service @@ -499,24 +499,24 @@ func (r *GatewayReconciler) determineL4ListenersFromService( } // take var copies of the address types so we can take pointers to them - gatewayIPAddrType := gatewayv1alpha2.IPAddressType - gatewayHostAddrType := gatewayv1alpha2.HostnameAddressType + gatewayIPAddrType := gatewayv1beta1.IPAddressType + gatewayHostAddrType := gatewayv1beta1.HostnameAddressType // for all service types we're going to capture the ClusterIP - addresses := make([]gatewayv1alpha2.GatewayAddress, 0, len(svc.Spec.ClusterIPs)) - listeners := make([]gatewayv1alpha2.Listener, 0, len(svc.Spec.Ports)) - protocolToRouteGroupKind := map[corev1.Protocol]gatewayv1alpha2.RouteGroupKind{ - corev1.ProtocolTCP: {Group: &gatewayV1alpha2Group, Kind: gatewayv1alpha2.Kind("TCPRoute")}, - corev1.ProtocolUDP: {Group: &gatewayV1alpha2Group, Kind: gatewayv1alpha2.Kind("UDPRoute")}, + addresses := make([]GatewayAddress, 0, len(svc.Spec.ClusterIPs)) + listeners := make([]Listener, 0, len(svc.Spec.Ports)) + protocolToRouteGroupKind := map[corev1.Protocol]gatewayv1beta1.RouteGroupKind{ + corev1.ProtocolTCP: {Group: &gatewayV1beta1Group, Kind: Kind("TCPRoute")}, + corev1.ProtocolUDP: {Group: &gatewayV1beta1Group, Kind: Kind("UDPRoute")}, } for _, port := range svc.Spec.Ports { - listeners = append(listeners, gatewayv1alpha2.Listener{ - Name: gatewayv1alpha2.SectionName(port.Name), - Protocol: gatewayv1alpha2.ProtocolType(port.Protocol), - Port: gatewayv1alpha2.PortNumber(port.Port), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{ + listeners = append(listeners, Listener{ + Name: (SectionName)(port.Name), + Protocol: (ProtocolType)(port.Protocol), + Port: (PortNumber)(port.Port), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{ protocolToRouteGroupKind[port.Protocol], }, }, @@ -538,13 +538,13 @@ func (r *GatewayReconciler) determineL4ListenersFromService( // are often the most common address used for traffic. for _, ingress := range svc.Status.LoadBalancer.Ingress { if ingress.IP != "" { - addresses = append([]gatewayv1alpha2.GatewayAddress{{ + addresses = append([]GatewayAddress{{ Type: &gatewayIPAddrType, Value: ingress.IP, }}, addresses...) } if ingress.Hostname != "" { - addresses = append([]gatewayv1alpha2.GatewayAddress{{ + addresses = append([]GatewayAddress{{ Type: &gatewayHostAddrType, Value: ingress.Hostname, }}, addresses...) @@ -565,7 +565,11 @@ func (r *GatewayReconciler) determineL4ListenersFromService( // determineListenersFromDataPlane takes a list of Gateway listeners and references // them against the data-plane to determine any higher level protocol (TLS, HTTP) // configured for them. -func (r *GatewayReconciler) determineListenersFromDataPlane(ctx context.Context, svc *corev1.Service, listeners []gatewayv1alpha2.Listener) ([]gatewayv1alpha2.Listener, error) { +func (r *GatewayReconciler) determineListenersFromDataPlane( + ctx context.Context, + svc *corev1.Service, + listeners []Listener, +) ([]Listener, error) { // gather the proxy and stream listeners from the data-plane and map them // to their respective ports (which will be the targetPorts of the proxy // Service in Kubernetes). @@ -591,31 +595,31 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(ctx context.Context, // upgrade existing L4 listeners with any higher level protocols that // are configured for them in the data-plane. - upgradedListeners := make([]gatewayv1alpha2.Listener, 0, len(listeners)) + upgradedListeners := make([]Listener, 0, len(listeners)) for _, listener := range listeners { if streamListener, ok := streamListenersMap[portMapper[int(listener.Port)]]; ok { if streamListener.SSL { - listener.Protocol = gatewayv1alpha2.TLSProtocolType - listener.AllowedRoutes = &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{ - {Group: &gatewayV1alpha2Group, Kind: gatewayv1alpha2.Kind("TLSRoute")}, + listener.Protocol = gatewayv1beta1.TLSProtocolType + listener.AllowedRoutes = &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{ + {Group: &gatewayV1beta1Group, Kind: (Kind)("TLSRoute")}, }, } } } if proxyListener, ok := proxyListenersMap[portMapper[int(listener.Port)]]; ok { if proxyListener.SSL { - listener.Protocol = gatewayv1alpha2.HTTPSProtocolType - listener.AllowedRoutes = &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{ - {Group: &gatewayV1alpha2Group, Kind: gatewayv1alpha2.Kind("HTTPRoute")}, + listener.Protocol = gatewayv1beta1.HTTPSProtocolType + listener.AllowedRoutes = &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{ + {Group: &gatewayV1beta1Group, Kind: (Kind)("HTTPRoute")}, }, } } else { - listener.Protocol = gatewayv1alpha2.HTTPProtocolType - listener.AllowedRoutes = &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{ - {Group: &gatewayV1alpha2Group, Kind: gatewayv1alpha2.Kind("HTTPRoute")}, + listener.Protocol = gatewayv1beta1.HTTPProtocolType + listener.AllowedRoutes = &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{ + {Group: &gatewayV1beta1Group, Kind: (Kind)("HTTPRoute")}, }, } } @@ -634,18 +638,18 @@ func (r *GatewayReconciler) determineListenersFromDataPlane(ctx context.Context, // If the addresses and listeners provided are the same as what exists, it is assumed that reconciliation is complete and a Ready condition is posted. func (r *GatewayReconciler) updateAddressesAndListenersStatus( ctx context.Context, - gateway *gatewayv1alpha2.Gateway, - listenerStatuses []gatewayv1alpha2.ListenerStatus, + gateway *gatewayv1beta1.Gateway, + listenerStatuses []gatewayv1beta1.ListenerStatus, ) (bool, error) { if !isGatewayReady(gateway) { gateway.Status.Listeners = listenerStatuses gateway.Status.Addresses = gateway.Spec.Addresses readyCondition := metav1.Condition{ - Type: string(gatewayv1alpha2.GatewayConditionReady), + Type: string(gatewayv1beta1.GatewayConditionReady), Status: metav1.ConditionTrue, ObservedGeneration: gateway.Generation, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.GatewayReasonReady), + Reason: string(gatewayv1beta1.GatewayReasonReady), Message: "addresses and listeners for the Gateway resource were successfully updated", } setGatewayCondition(gateway, readyCondition) diff --git a/internal/controllers/gateway/gateway_controller_test.go b/internal/controllers/gateway/gateway_controller_test.go index bd59de1447..84814ef363 100644 --- a/internal/controllers/gateway/gateway_controller_test.go +++ b/internal/controllers/gateway/gateway_controller_test.go @@ -17,45 +17,45 @@ import ( func Test_readyConditionExistsForObservedGeneration(t *testing.T) { t.Log("checking ready condition for currently ready gateway") - currentlyReadyGateway := &gatewayv1alpha2.Gateway{ + currentlyReadyGateway := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Generation: 1, }, - Status: gatewayv1alpha2.GatewayStatus{ + Status: gatewayv1beta1.GatewayStatus{ Conditions: []metav1.Condition{{ - Type: string(gatewayv1alpha2.GatewayConditionReady), + Type: string(gatewayv1beta1.GatewayConditionReady), Status: metav1.ConditionTrue, ObservedGeneration: 1, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.GatewayReasonReady), + Reason: string(gatewayv1beta1.GatewayReasonReady), }}, }, } assert.True(t, isGatewayReady(currentlyReadyGateway)) t.Log("checking ready condition for previously ready gateway that has since been updated") - previouslyReadyGateway := &gatewayv1alpha2.Gateway{ + previouslyReadyGateway := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Generation: 2, }, - Status: gatewayv1alpha2.GatewayStatus{ + Status: gatewayv1beta1.GatewayStatus{ Conditions: []metav1.Condition{{ - Type: string(gatewayv1alpha2.GatewayConditionReady), + Type: string(gatewayv1beta1.GatewayConditionReady), Status: metav1.ConditionTrue, ObservedGeneration: 1, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.GatewayReasonReady), + Reason: string(gatewayv1beta1.GatewayReasonReady), }}, }, } assert.False(t, isGatewayReady(previouslyReadyGateway)) t.Log("checking ready condition for a gateway which has never been ready") - neverBeenReadyGateway := &gatewayv1alpha2.Gateway{ + neverBeenReadyGateway := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Generation: 10, }, - Status: gatewayv1alpha2.GatewayStatus{}, + Status: gatewayv1beta1.GatewayStatus{}, } assert.False(t, isGatewayReady(neverBeenReadyGateway)) } @@ -63,13 +63,13 @@ func Test_readyConditionExistsForObservedGeneration(t *testing.T) { func Test_setGatewayCondtion(t *testing.T) { testCases := []struct { name string - gw *gatewayv1alpha2.Gateway + gw *gatewayv1beta1.Gateway condition metav1.Condition conditionLength int }{ { name: "no_such_condition_should_append_one", - gw: &gatewayv1alpha2.Gateway{}, + gw: &gatewayv1beta1.Gateway{}, condition: metav1.Condition{ Type: "fake1", Status: metav1.ConditionTrue, @@ -81,8 +81,8 @@ func Test_setGatewayCondtion(t *testing.T) { }, { name: "have_condition_with_type_should_replace", - gw: &gatewayv1alpha2.Gateway{ - Status: gatewayv1alpha2.GatewayStatus{ + gw: &gatewayv1beta1.Gateway{ + Status: gatewayv1beta1.GatewayStatus{ Conditions: []metav1.Condition{ { Type: "fake1", @@ -105,8 +105,8 @@ func Test_setGatewayCondtion(t *testing.T) { }, { name: "multiple_conditions_with_type_should_preserve_one", - gw: &gatewayv1alpha2.Gateway{ - Status: gatewayv1alpha2.GatewayStatus{ + gw: &gatewayv1beta1.Gateway{ + Status: gatewayv1beta1.GatewayStatus{ Conditions: []metav1.Condition{ { Type: "fake1", @@ -166,21 +166,21 @@ func Test_setGatewayCondtion(t *testing.T) { func Test_isGatewayMarkedAsScheduled(t *testing.T) { t.Log("verifying scheduled check for gateway object which has been scheduled") - scheduledGateway := &gatewayv1alpha2.Gateway{ - Status: gatewayv1alpha2.GatewayStatus{ + scheduledGateway := &gatewayv1beta1.Gateway{ + Status: gatewayv1beta1.GatewayStatus{ Conditions: []metav1.Condition{{ - Type: string(gatewayv1alpha2.GatewayConditionScheduled), + Type: string(gatewayv1beta1.GatewayConditionScheduled), Status: metav1.ConditionTrue, ObservedGeneration: 1, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.GatewayReasonScheduled), + Reason: string(gatewayv1beta1.GatewayReasonScheduled), }}, }, } assert.True(t, isGatewayScheduled(scheduledGateway)) t.Log("verifying scheduled check for gateway object which has not been scheduled") - unscheduledGateway := &gatewayv1alpha2.Gateway{} + unscheduledGateway := &gatewayv1beta1.Gateway{} assert.False(t, isGatewayScheduled(unscheduledGateway)) } @@ -203,7 +203,7 @@ func Test_getRefFromPublishService(t *testing.T) { func Test_pruneStatusConditions(t *testing.T) { t.Log("verifying that a gateway with minimal status conditions is not pruned") - gateway := &gatewayv1alpha2.Gateway{} + gateway := &gatewayv1beta1.Gateway{} for i := 0; i < 4; i++ { gateway.Status.Conditions = append(gateway.Status.Conditions, metav1.Condition{Type: "fake", ObservedGeneration: int64(i)}) } @@ -241,14 +241,14 @@ func Test_reconcileGatewaysIfClassMatches(t *testing.T) { } t.Log("generating a list of matching controllers") - matching := []gatewayv1alpha2.Gateway{ + matching := []gatewayv1beta1.Gateway{ { ObjectMeta: metav1.ObjectMeta{ Name: "sanfrancisco", Namespace: "california", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(gatewayClass.Name), + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(gatewayClass.Name), }, }, { @@ -256,8 +256,8 @@ func Test_reconcileGatewaysIfClassMatches(t *testing.T) { Name: "sandiego", Namespace: "california", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(gatewayClass.Name), + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(gatewayClass.Name), }, }, { @@ -265,21 +265,21 @@ func Test_reconcileGatewaysIfClassMatches(t *testing.T) { Name: "losangelos", Namespace: "california", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(gatewayClass.Name), + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(gatewayClass.Name), }, }, } t.Log("generating a list of non-matching controllers") - nonmatching := []gatewayv1alpha2.Gateway{ + nonmatching := []gatewayv1beta1.Gateway{ { ObjectMeta: metav1.ObjectMeta{ Name: "hamburg", Namespace: "germany", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName("eu"), + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName("eu"), }, }, { @@ -287,8 +287,8 @@ func Test_reconcileGatewaysIfClassMatches(t *testing.T) { Name: "paris", Namespace: "france", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName("eu"), + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName("eu"), }, }, } @@ -346,7 +346,7 @@ func Test_isGatewayControlledAndUnmanagedMode(t *testing.T) { } t.Log("creating an unmanaged mode enabled gateway") - unmanagedGateway := gatewayv1alpha2.Gateway{ + unmanagedGateway := gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Annotations: map[string]string{ @@ -356,8 +356,8 @@ func Test_isGatewayControlledAndUnmanagedMode(t *testing.T) { } t.Log("verifying the results for several gateways") - assert.False(t, isGatewayInClassAndUnmanaged(controlledGatewayClass, gatewayv1alpha2.Gateway{})) - assert.False(t, isGatewayInClassAndUnmanaged(uncontrolledGatewayClass, gatewayv1alpha2.Gateway{})) + assert.False(t, isGatewayInClassAndUnmanaged(controlledGatewayClass, gatewayv1beta1.Gateway{})) + assert.False(t, isGatewayInClassAndUnmanaged(uncontrolledGatewayClass, gatewayv1beta1.Gateway{})) assert.False(t, isGatewayInClassAndUnmanaged(uncontrolledGatewayClass, unmanagedGateway)) assert.True(t, isGatewayInClassAndUnmanaged(controlledGatewayClass, unmanagedGateway)) } @@ -517,14 +517,14 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { testCases := []struct { name string gatewayNamespace string - certRef gatewayv1alpha2.SecretObjectReference + certRef gatewayv1beta1.SecretObjectReference referenceGrants []gatewayv1alpha2.ReferenceGrant expectedReason string }{ { name: "no need for reference", gatewayNamespace: "test", - certRef: gatewayv1alpha2.SecretObjectReference{ + certRef: gatewayv1beta1.SecretObjectReference{ Kind: util.StringToGatewayAPIKindPtr("Secret"), Name: "testSecret", }, @@ -533,10 +533,10 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { { name: "reference not granted", gatewayNamespace: "test", - certRef: gatewayv1alpha2.SecretObjectReference{ + certRef: gatewayv1beta1.SecretObjectReference{ Kind: util.StringToGatewayAPIKindPtr("Secret"), Name: "testSecret", - Namespace: (*gatewayv1alpha2.Namespace)(pointer.StringPtr("otherNamespace")), + Namespace: (*Namespace)(pointer.StringPtr("otherNamespace")), }, referenceGrants: []gatewayv1alpha2.ReferenceGrant{ { @@ -546,7 +546,7 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { Spec: gatewayv1alpha2.ReferenceGrantSpec{ From: []gatewayv1alpha2.ReferenceGrantFrom{ { - Group: gatewayV1alpha2Group, + Group: (gatewayv1alpha2.Group)(gatewayV1beta1Group), Kind: "Gateway", Namespace: "test", }, @@ -566,10 +566,10 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { { name: "reference granted, secret name not specified", gatewayNamespace: "test", - certRef: gatewayv1alpha2.SecretObjectReference{ + certRef: gatewayv1beta1.SecretObjectReference{ Kind: util.StringToGatewayAPIKindPtr("Secret"), Name: "testSecret", - Namespace: (*gatewayv1alpha2.Namespace)(pointer.StringPtr("otherNamespace")), + Namespace: (*Namespace)(pointer.StringPtr("otherNamespace")), }, referenceGrants: []gatewayv1alpha2.ReferenceGrant{ { @@ -586,7 +586,7 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { }, // good entry { - Group: gatewayV1alpha2Group, + Group: (gatewayv1alpha2.Group)(gatewayV1beta1Group), Kind: "Gateway", Namespace: "test", }, @@ -605,10 +605,10 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { { name: "reference granted, secret name specified", gatewayNamespace: "test", - certRef: gatewayv1alpha2.SecretObjectReference{ + certRef: gatewayv1beta1.SecretObjectReference{ Kind: util.StringToGatewayAPIKindPtr("Secret"), Name: "testSecret", - Namespace: (*gatewayv1alpha2.Namespace)(pointer.StringPtr("otherNamespace")), + Namespace: (*Namespace)(pointer.StringPtr("otherNamespace")), }, referenceGrants: []gatewayv1alpha2.ReferenceGrant{ { @@ -618,7 +618,7 @@ func Test_getReferenceGrantConditionReason(t *testing.T) { Spec: gatewayv1alpha2.ReferenceGrantSpec{ From: []gatewayv1alpha2.ReferenceGrantFrom{ { - Group: gatewayV1alpha2Group, + Group: (gatewayv1alpha2.Group)(gatewayV1beta1Group), Kind: "Gateway", Namespace: "test", }, diff --git a/internal/controllers/gateway/gateway_utils.go b/internal/controllers/gateway/gateway_utils.go index 9cedc76b0e..07dca3f9b6 100644 --- a/internal/controllers/gateway/gateway_utils.go +++ b/internal/controllers/gateway/gateway_utils.go @@ -31,7 +31,7 @@ const ( // to expected condition in newCondition. // if the gateway status does not contain a condition with that type, add one more condition. // if the gateway status contains condition(s) with the type, then replace with the new condition. -func setGatewayCondition(gateway *gatewayv1alpha2.Gateway, newCondition metav1.Condition) { +func setGatewayCondition(gateway *Gateway, newCondition metav1.Condition) { newConditions := []metav1.Condition{} for _, condition := range gateway.Status.Conditions { if condition.Type != newCondition.Type { @@ -44,10 +44,10 @@ func setGatewayCondition(gateway *gatewayv1alpha2.Gateway, newCondition metav1.C // isGatewayScheduled returns boolean whether or not the gateway object was scheduled // previously by the gateway controller. -func isGatewayScheduled(gateway *gatewayv1alpha2.Gateway) bool { +func isGatewayScheduled(gateway *Gateway) bool { for _, cond := range gateway.Status.Conditions { - if cond.Type == string(gatewayv1alpha2.GatewayConditionScheduled) && - cond.Reason == string(gatewayv1alpha2.GatewayReasonScheduled) && + if cond.Type == string(gatewayv1beta1.GatewayConditionScheduled) && + cond.Reason == string(gatewayv1beta1.GatewayReasonScheduled) && cond.Status == metav1.ConditionTrue { return true } @@ -57,9 +57,9 @@ func isGatewayScheduled(gateway *gatewayv1alpha2.Gateway) bool { // isGatewayReady returns boolean whether the ready condition exists // for the given gateway object if it matches the currently known generation of that object. -func isGatewayReady(gateway *gatewayv1alpha2.Gateway) bool { +func isGatewayReady(gateway *Gateway) bool { for _, cond := range gateway.Status.Conditions { - if cond.Type == string(gatewayv1alpha2.GatewayConditionReady) && cond.Reason == string(gatewayv1alpha2.GatewayReasonReady) && cond.ObservedGeneration == gateway.Generation { + if cond.Type == string(gatewayv1beta1.GatewayConditionReady) && cond.Reason == string(gatewayv1beta1.GatewayReasonReady) && cond.ObservedGeneration == gateway.Generation { return true } } @@ -68,7 +68,7 @@ func isGatewayReady(gateway *gatewayv1alpha2.Gateway) bool { // isGatewayInClassAndUnmanaged returns boolean if the provided combination of gateway and class // is controlled by this controller and the gateway is configured for unmanaged mode. -func isGatewayInClassAndUnmanaged(gatewayClass *gatewayv1beta1.GatewayClass, gateway gatewayv1alpha2.Gateway) bool { +func isGatewayInClassAndUnmanaged(gatewayClass *GatewayClass, gateway Gateway) bool { _, ok := annotations.ExtractUnmanagedGatewayMode(gateway.Annotations) return ok && gatewayClass.Spec.ControllerName == ControllerName } @@ -88,7 +88,7 @@ func getRefFromPublishService(publishService string) (types.NamespacedName, erro // pruneGatewayStatusConds cleans out old status conditions if the Gateway currently has more // status conditions set than the 8 maximum allowed by the Kubernetes API. -func pruneGatewayStatusConds(gateway *gatewayv1alpha2.Gateway) *gatewayv1alpha2.Gateway { +func pruneGatewayStatusConds(gateway *Gateway) *Gateway { if len(gateway.Status.Conditions) > maxConds { gateway.Status.Conditions = gateway.Status.Conditions[len(gateway.Status.Conditions)-maxConds:] } @@ -97,7 +97,7 @@ func pruneGatewayStatusConds(gateway *gatewayv1alpha2.Gateway) *gatewayv1alpha2. // reconcileGatewaysIfClassMatches is a filter function to convert a list of gateways into a list // of reconciliation requests for those gateways based on which match the given class. -func reconcileGatewaysIfClassMatches(gatewayClass client.Object, gateways []gatewayv1alpha2.Gateway) (recs []reconcile.Request) { +func reconcileGatewaysIfClassMatches(gatewayClass client.Object, gateways []Gateway) (recs []reconcile.Request) { for _, gateway := range gateways { if string(gateway.Spec.GatewayClassName) == gatewayClass.GetName() { recs = append(recs, reconcile.Request{ @@ -115,16 +115,17 @@ func reconcileGatewaysIfClassMatches(gatewayClass client.Object, gateways []gate // reconciliation. type ListenerTracker struct { // actual listeners - Listeners map[gatewayv1alpha2.SectionName]gatewayv1alpha2.Listener + Listeners map[SectionName]Listener // statuses - Statuses map[gatewayv1alpha2.SectionName]gatewayv1alpha2.ListenerStatus + Statuses map[SectionName]ListenerStatus + // protocol to port to number map (var protocols) - protocolToPort map[gatewayv1alpha2.ProtocolType]map[gatewayv1alpha2.PortNumber]bool + protocolToPort map[ProtocolType]map[PortNumber]bool // port to protocol map (portsToProtocol) - portToProtocol map[gatewayv1alpha2.PortNumber]gatewayv1alpha2.ProtocolType + portToProtocol map[PortNumber]ProtocolType // port to hostname to listener name map (portsToHostnames) - portsToHostnames map[gatewayv1alpha2.PortNumber]map[gatewayv1alpha2.Hostname]gatewayv1alpha2.SectionName + portsToHostnames map[PortNumber]map[Hostname]SectionName } // update from existing becomes moot if we're stateful, correct? @@ -134,27 +135,27 @@ type ListenerTracker struct { // NewListenerTracker returns a ListenerTracker with empty maps. func NewListenerTracker() ListenerTracker { return ListenerTracker{ - Statuses: map[gatewayv1alpha2.SectionName]gatewayv1alpha2.ListenerStatus{}, - Listeners: map[gatewayv1alpha2.SectionName]gatewayv1alpha2.Listener{}, - protocolToPort: map[gatewayv1alpha2.ProtocolType]map[gatewayv1alpha2.PortNumber]bool{}, - portToProtocol: map[gatewayv1alpha2.PortNumber]gatewayv1alpha2.ProtocolType{}, - portsToHostnames: map[gatewayv1alpha2.PortNumber]map[gatewayv1alpha2.Hostname]gatewayv1alpha2.SectionName{}, + Statuses: map[SectionName]ListenerStatus{}, + Listeners: map[SectionName]Listener{}, + protocolToPort: map[ProtocolType]map[PortNumber]bool{}, + portToProtocol: map[PortNumber]ProtocolType{}, + portsToHostnames: map[PortNumber]map[Hostname]SectionName{}, } } type ( - protocolPortMap map[gatewayv1alpha2.ProtocolType]map[gatewayv1alpha2.PortNumber]bool - portProtocolMap map[gatewayv1alpha2.PortNumber]gatewayv1alpha2.ProtocolType - portHostnameMap map[gatewayv1alpha2.PortNumber]map[gatewayv1alpha2.Hostname]bool - listenerAttachedMap map[gatewayv1alpha2.SectionName]int32 + protocolPortMap map[ProtocolType]map[PortNumber]bool + portProtocolMap map[PortNumber]ProtocolType + portHostnameMap map[PortNumber]map[Hostname]bool + listenerAttachedMap map[SectionName]int32 ) -func buildKongPortMap(listens []gatewayv1alpha2.Listener) protocolPortMap { - p := make(map[gatewayv1alpha2.ProtocolType]map[gatewayv1alpha2.PortNumber]bool, len(listens)) +func buildKongPortMap(listens []Listener) protocolPortMap { + p := make(map[ProtocolType]map[PortNumber]bool, len(listens)) for _, listen := range listens { _, ok := p[listen.Protocol] if !ok { - p[listen.Protocol] = map[gatewayv1alpha2.PortNumber]bool{} + p[listen.Protocol] = map[PortNumber]bool{} } p[listen.Protocol][listen.Port] = true } @@ -164,7 +165,7 @@ func buildKongPortMap(listens []gatewayv1alpha2.Listener) protocolPortMap { // initializeListenerMaps takes a Gateway and builds indices used in status updates and conflict detection. It returns // empty maps from port to protocol to listener name and from port to hostnames, and a populated map from listener name // to attached route count from their status. -func initializeListenerMaps(gateway *gatewayv1alpha2.Gateway) ( +func initializeListenerMaps(gateway *Gateway) ( portProtocolMap, portHostnameMap, listenerAttachedMap, @@ -173,14 +174,14 @@ func initializeListenerMaps(gateway *gatewayv1alpha2.Gateway) ( portToHostname := make(portHostnameMap, len(gateway.Status.Listeners)) listenerToAttached := make(listenerAttachedMap, len(gateway.Status.Listeners)) - existingStatuses := make(map[gatewayv1alpha2.SectionName]gatewayv1alpha2.ListenerStatus, + existingStatuses := make(map[SectionName]ListenerStatus, len(gateway.Status.Listeners)) for _, listenerStatus := range gateway.Status.Listeners { existingStatuses[listenerStatus.Name] = listenerStatus } for _, listener := range gateway.Spec.Listeners { - portToHostname[listener.Port] = make(map[gatewayv1alpha2.Hostname]bool) + portToHostname[listener.Port] = make(map[Hostname]bool) if existingStatus, ok := existingStatuses[listener.Name]; ok { listenerToAttached[listener.Name] = existingStatus.AttachedRoutes } else { @@ -190,27 +191,29 @@ func initializeListenerMaps(gateway *gatewayv1alpha2.Gateway) ( return portToProtocol, portToHostname, listenerToAttached } -func canSharePort(requested gatewayv1alpha2.ProtocolType, existing gatewayv1alpha2.ProtocolType) bool { +func canSharePort(requested, existing ProtocolType) bool { switch requested { // TCP and UDP listeners must always use unique ports - case gatewayv1alpha2.TCPProtocolType, gatewayv1alpha2.UDPProtocolType: + case (ProtocolType)(gatewayv1alpha2.TCPProtocolType), (ProtocolType)(gatewayv1alpha2.UDPProtocolType): return false // HTTPS and TLS Listeners can share ports with others of their type or the other TLS type // note that this is not actually possible in Kong: TLS is a stream listen and HTTPS is an http listen // however, this section implements the spec ignoring Kong's reality - case gatewayv1alpha2.HTTPSProtocolType: - if existing == gatewayv1alpha2.HTTPSProtocolType || existing == gatewayv1alpha2.TLSProtocolType { + case (ProtocolType)(gatewayv1alpha2.HTTPSProtocolType): + if existing == (ProtocolType)(gatewayv1alpha2.HTTPSProtocolType) || + existing == (ProtocolType)(gatewayv1alpha2.TLSProtocolType) { return true } return false - case gatewayv1alpha2.TLSProtocolType: - if existing == gatewayv1alpha2.HTTPSProtocolType || existing == gatewayv1alpha2.TLSProtocolType { + case (ProtocolType)(gatewayv1alpha2.TLSProtocolType): + if existing == (ProtocolType)(gatewayv1alpha2.HTTPSProtocolType) || + existing == (ProtocolType)(gatewayv1alpha2.TLSProtocolType) { return true } return false // HTTP Listeners can share ports with others of the same protocol only - case gatewayv1alpha2.HTTPProtocolType: - if existing == gatewayv1alpha2.HTTPProtocolType { + case gatewayv1beta1.HTTPProtocolType: + if existing == gatewayv1beta1.HTTPProtocolType { return true } return false @@ -220,24 +223,24 @@ func canSharePort(requested gatewayv1alpha2.ProtocolType, existing gatewayv1alph } func getListenerStatus( - gateway *gatewayv1alpha2.Gateway, - kongListens []gatewayv1alpha2.Listener, + gateway *Gateway, + kongListens []Listener, referenceGrants []gatewayv1alpha2.ReferenceGrant, -) []gatewayv1alpha2.ListenerStatus { - statuses := make(map[gatewayv1alpha2.SectionName]gatewayv1alpha2.ListenerStatus, len(gateway.Spec.Listeners)) +) []ListenerStatus { + statuses := make(map[SectionName]ListenerStatus, len(gateway.Spec.Listeners)) portToProtocol, portToHostname, listenerToAttached := initializeListenerMaps(gateway) kongProtocolsToPort := buildKongPortMap(kongListens) - conflictedPorts := make(map[gatewayv1alpha2.PortNumber]bool, len(gateway.Spec.Listeners)) - conflictedHostnames := make(map[gatewayv1alpha2.PortNumber]map[gatewayv1alpha2.Hostname]bool, len(gateway.Spec.Listeners)) + conflictedPorts := make(map[PortNumber]bool, len(gateway.Spec.Listeners)) + conflictedHostnames := make(map[PortNumber]map[Hostname]bool, len(gateway.Spec.Listeners)) // TODO we should check transition time rather than always nowing, which we do throughout the below // https://github.com/Kong/kubernetes-ingress-controller/issues/2556 for _, listener := range gateway.Spec.Listeners { - var hostname gatewayv1alpha2.Hostname + var hostname Hostname if listener.Hostname != nil { hostname = *listener.Hostname } - status := gatewayv1alpha2.ListenerStatus{ + status := ListenerStatus{ Name: listener.Name, Conditions: []metav1.Condition{}, SupportedKinds: supportedRouteGroupKinds, @@ -254,11 +257,11 @@ func getListenerStatus( } else { if !canSharePort(listener.Protocol, portToProtocol[listener.Port]) { status.Conditions = append(status.Conditions, metav1.Condition{ - Type: string(gatewayv1alpha2.ListenerConditionConflicted), + Type: string(gatewayv1beta1.ListenerConditionConflicted), Status: metav1.ConditionTrue, ObservedGeneration: gateway.Generation, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.ListenerReasonProtocolConflict), + Reason: string(gatewayv1beta1.ListenerReasonProtocolConflict), }) conflictedPorts[listener.Port] = true } else { @@ -274,7 +277,7 @@ func getListenerStatus( // you have also added a phantom Listener for hostname example.com and port 8200, because Kong will // serve the route on both. See https://github.com/Kong/kubernetes-ingress-controller/issues/2606 if conflictedHostnames[listener.Port] == nil { - conflictedHostnames[listener.Port] = map[gatewayv1alpha2.Hostname]bool{} + conflictedHostnames[listener.Port] = map[Hostname]bool{} } if _, exists := portToHostname[listener.Port][hostname]; !exists { portToHostname[listener.Port][hostname] = true @@ -370,7 +373,7 @@ func getListenerStatus( var conflictReason string var resolvedRefReason string - var hostname gatewayv1alpha2.Hostname + var hostname Hostname if listener.Hostname != nil { hostname = *listener.Hostname } @@ -395,7 +398,7 @@ func getListenerStatus( break } // if the certificate is in the same namespace of the gateway, no ReferenceGrant is needed - if certRef.Namespace == nil || *certRef.Namespace == gatewayv1alpha2.Namespace(gateway.Namespace) { + if certRef.Namespace == nil || *certRef.Namespace == (Namespace)(gateway.Namespace) { continue } // get the result of the certificate reference. If the returned reason is not successful, the loop @@ -479,7 +482,7 @@ func getListenerStatus( statuses[listener.Name] = status } } - statusArray := []gatewayv1alpha2.ListenerStatus{} + statusArray := []ListenerStatus{} for _, status := range statuses { statusArray = append(statusArray, status) } @@ -488,9 +491,13 @@ func getListenerStatus( } // getReferenceGrantConditionReason gets a certRef belonging to a specific listener and a slice of referenceGrants. -func getReferenceGrantConditionReason(gatewayNamespace string, certRef gatewayv1alpha2.SecretObjectReference, referenceGrants []gatewayv1alpha2.ReferenceGrant) string { +func getReferenceGrantConditionReason( + gatewayNamespace string, + certRef gatewayv1beta1.SecretObjectReference, + referenceGrants []gatewayv1alpha2.ReferenceGrant, +) string { // no need to have this reference granted - if certRef.Namespace == nil || *certRef.Namespace == gatewayv1alpha2.Namespace(gatewayNamespace) { + if certRef.Namespace == nil || *certRef.Namespace == (Namespace)(gatewayNamespace) { return string(gatewayv1alpha2.ListenerReasonResolvedRefs) } @@ -502,7 +509,7 @@ func getReferenceGrantConditionReason(gatewayNamespace string, certRef gatewayv1 } for _, from := range grant.Spec.From { // we are interested only in grants for gateways that want to reference secrets - if from.Group != gatewayV1alpha2Group || from.Kind != "Gateway" { + if (Group)(from.Group) != gatewayV1beta1Group || from.Kind != "Gateway" { continue } if from.Namespace == gatewayv1alpha2.Namespace(gatewayNamespace) { @@ -548,7 +555,7 @@ func isGatewayClassEventInClass(log logr.Logger, watchEvent interface{}) bool { } for _, obj := range objs { - gwc, ok := obj.(*gatewayv1beta1.GatewayClass) + gwc, ok := obj.(*GatewayClass) if !ok { log.Error(fmt.Errorf("invalid type"), "received invalid object type in event handlers", "expected", "GatewayClass", "found", reflect.TypeOf(obj)) continue diff --git a/internal/controllers/gateway/httproute_controller.go b/internal/controllers/gateway/httproute_controller.go index db16b97619..fbe33e62ae 100644 --- a/internal/controllers/gateway/httproute_controller.go +++ b/internal/controllers/gateway/httproute_controller.go @@ -78,7 +78,7 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // removed from data-plane configurations, and any routes that are now supported // due to that change get added to data-plane configurations. if err := c.Watch( - &source.Kind{Type: &gatewayv1alpha2.Gateway{}}, + &source.Kind{Type: &gatewayv1beta1.Gateway{}}, handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGateway), ); err != nil { return err @@ -114,7 +114,7 @@ func (r *HTTPRouteReconciler) listHTTPRoutesForGatewayClass(obj client.Object) [ } // map all Gateway objects - gatewayList := gatewayv1alpha2.GatewayList{} + gatewayList := gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), &gatewayList); err != nil { r.Log.Error(err, "failed to list gateway objects from the cached client") return nil @@ -192,7 +192,7 @@ func (r *HTTPRouteReconciler) listHTTPRoutesForGatewayClass(obj client.Object) [ // this kind of problem without having to enqueue extra objects. func (r *HTTPRouteReconciler) listHTTPRoutesForGateway(obj client.Object) []reconcile.Request { // verify that the object is a Gateway - gw, ok := obj.(*gatewayv1alpha2.Gateway) + gw, ok := obj.(*gatewayv1beta1.Gateway) if !ok { r.Log.Error(fmt.Errorf("invalid type"), "found invalid type in event handlers", "expected", "Gateway", "found", reflect.TypeOf(obj)) return nil @@ -387,9 +387,9 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont for _, gateway := range gateways { // build a new status for the parent Gateway gatewayParentStatus := &gatewayv1beta1.RouteParentStatus{ - ParentRef: gatewayv1beta1.ParentReference{ + ParentRef: ParentReference{ Group: (*gatewayv1beta1.Group)(&gatewayv1beta1.GroupVersion.Group), - Kind: util.StringToGatewayAPIKindV1Beta1Ptr(httprouteParentKind), + Kind: util.StringToGatewayAPIKindPtr(httprouteParentKind), Namespace: (*gatewayv1beta1.Namespace)(&gateway.gateway.Namespace), Name: gatewayv1beta1.ObjectName(gateway.gateway.Name), }, @@ -403,7 +403,7 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont }}, } if gateway.listenerName != "" { - gatewayParentStatus.ParentRef.SectionName = (*gatewayv1beta1.SectionName)(pointer.StringPtr(gateway.listenerName)) + gatewayParentStatus.ParentRef.SectionName = (*SectionName)(pointer.StringPtr(gateway.listenerName)) } key := fmt.Sprintf("%s/%s/%s", gateway.gateway.Namespace, gateway.gateway.Name, gateway.listenerName) diff --git a/internal/controllers/gateway/route_utils.go b/internal/controllers/gateway/route_utils.go index 037cd7e0ee..05231005a2 100644 --- a/internal/controllers/gateway/route_utils.go +++ b/internal/controllers/gateway/route_utils.go @@ -27,29 +27,29 @@ const ( // supportedGatewayWithCondition is a struct that wraps a gateway and some further info // such as the condition Status condition Accepted of the gateway and the listenerName. type supportedGatewayWithCondition struct { - gateway *gatewayv1alpha2.Gateway + gateway *Gateway condition metav1.Condition listenerName string } // parentRefsForRoute provides a list of the parentRefs given a Gateway APIs route object // (e.g. HTTPRoute, TCPRoute, e.t.c.) which refer to the Gateway resource(s) which manage it. -func parentRefsForRoute[T types.RouteT](route T) ([]gatewayv1beta1.ParentReference, error) { +func parentRefsForRoute[T types.RouteT](route T) ([]ParentReference, error) { // Note: Ideally we wouldn't have to do this but it's hard to juggle around types - // and support gatewayv1beta1.ParentReference and gatewayv1alpha2.ParentReference + // and support ParentReference and gatewayv1alpha2.ParentReference // at the same time so we just copy v1alpha2 refs to a new v1beta1 slice. convertV1Alpha2ToV1Beta1ParentReference := func( refsAlpha []gatewayv1alpha2.ParentReference, - ) []gatewayv1beta1.ParentReference { - ret := make([]gatewayv1beta1.ParentReference, len(refsAlpha)) + ) []ParentReference { + ret := make([]ParentReference, len(refsAlpha)) for i, v := range refsAlpha { - ret[i] = gatewayv1beta1.ParentReference{ + ret[i] = ParentReference{ Group: (*gatewayv1beta1.Group)(v.Group), - Kind: (*gatewayv1beta1.Kind)(v.Kind), + Kind: (*Kind)(v.Kind), Namespace: (*gatewayv1beta1.Namespace)(v.Namespace), Name: (gatewayv1beta1.ObjectName)(v.Name), - SectionName: (*gatewayv1beta1.SectionName)(v.SectionName), - Port: (*gatewayv1beta1.PortNumber)(v.Port), + SectionName: (*SectionName)(v.SectionName), + Port: (*PortNumber)(v.Port), } } return ret @@ -94,7 +94,7 @@ func getSupportedGatewayForRoute[T types.RouteT](ctx context.Context, mgrc clien name := string(parentRef.Name) // pull the Gateway object from the cached client - gateway := gatewayv1alpha2.Gateway{} + gateway := gatewayv1beta1.Gateway{} if err := mgrc.Get(ctx, client.ObjectKey{ Namespace: namespace, Name: name, @@ -139,21 +139,21 @@ func getSupportedGatewayForRoute[T types.RouteT](ctx context.Context, mgrc clien case *gatewayv1beta1.HTTPRoute: hostnames := r.Spec.Hostnames oneHostnameMatch = listenerHostnameIntersectWithRouteHostnames(listener, hostnames) - if !(listener.Protocol == gatewayv1alpha2.HTTPProtocolType || listener.Protocol == gatewayv1alpha2.HTTPSProtocolType) { + if !(listener.Protocol == HTTPProtocolType || listener.Protocol == HTTPSProtocolType) { continue } case *gatewayv1alpha2.TCPRoute: - if listener.Protocol != gatewayv1alpha2.TCPProtocolType { + if listener.Protocol != (ProtocolType)(TCPProtocolType) { continue } case *gatewayv1alpha2.UDPRoute: - if listener.Protocol != gatewayv1alpha2.UDPProtocolType { + if listener.Protocol != (ProtocolType)(UDPProtocolType) { continue } case *gatewayv1alpha2.TLSRoute: hostnames := r.Spec.Hostnames oneHostnameMatch = listenerHostnameIntersectWithRouteHostnames(listener, hostnames) - if listener.Protocol != gatewayv1alpha2.TLSProtocolType { + if listener.Protocol != (ProtocolType)(TLSProtocolType) { continue } default: @@ -164,12 +164,12 @@ func getSupportedGatewayForRoute[T types.RouteT](ctx context.Context, mgrc clien } if listener.AllowedRoutes != nil { filtered = true - if *listener.AllowedRoutes.Namespaces.From == gatewayv1alpha2.NamespacesFromAll { + if *listener.AllowedRoutes.Namespaces.From == gatewayv1beta1.NamespacesFromAll { // we allow "all" by just stuffing the namespace we want to find into the map allowedNamespaces[route.GetNamespace()] = nil - } else if *listener.AllowedRoutes.Namespaces.From == gatewayv1alpha2.NamespacesFromSame { + } else if *listener.AllowedRoutes.Namespaces.From == gatewayv1beta1.NamespacesFromSame { allowedNamespaces[gateway.ObjectMeta.Namespace] = nil - } else if *listener.AllowedRoutes.Namespaces.From == gatewayv1alpha2.NamespacesFromSelector { + } else if *listener.AllowedRoutes.Namespaces.From == gatewayv1beta1.NamespacesFromSelector { namespaces := &corev1.NamespaceList{} selector, err := metav1.LabelSelectorAsSelector(listener.AllowedRoutes.Namespaces.Selector) if err != nil { @@ -241,7 +241,7 @@ func listenerHostnameIntersectWithRouteHostnames[H types.HostnameT, L types.List return true } } - case gatewayv1beta1.Listener: + case Listener: if l.Hostname == nil || *l.Hostname == "" { return true } @@ -267,7 +267,7 @@ func filterHostnames(gateways []supportedGatewayWithCondition, httpRoute *gatewa if len(httpRoute.Spec.Hostnames) == 0 { for _, gateway := range gateways { for _, listener := range gateway.gateway.Spec.Listeners { - if listenerName := gatewayv1alpha2.SectionName(gateway.listenerName); listenerName == "" || listenerName == listener.Name { + if listenerName := gateway.listenerName; listenerName == "" || listenerName == string(listener.Name) { if listener.Hostname != nil { filteredHostnames = append(filteredHostnames, (gatewayv1beta1.Hostname)(*listener.Hostname)) } @@ -297,8 +297,8 @@ func getMinimumHostnameIntersection(gateways []supportedGatewayWithCondition, ho for _, gateway := range gateways { for _, listener := range gateway.gateway.Spec.Listeners { // if the listenerName is specified and matches the name of the gateway listener proceed - if (gatewayv1beta1.SectionName)(gateway.listenerName) == "" || - (gatewayv1beta1.SectionName)(gateway.listenerName) == (gatewayv1beta1.SectionName)(listener.Name) { + if (SectionName)(gateway.listenerName) == "" || + (SectionName)(gateway.listenerName) == (SectionName)(listener.Name) { if listener.Hostname == nil || *listener.Hostname == "" { return hostname } @@ -326,7 +326,7 @@ func isRouteAccepted(gateways []supportedGatewayWithCondition) bool { // isHTTPReferenceGranted checks that the backendRef referenced by the HTTPRoute is granted by a ReferenceGrant. func isHTTPReferenceGranted(grantSpec gatewayv1alpha2.ReferenceGrantSpec, backendRef gatewayv1beta1.HTTPBackendRef, fromNamespace string) bool { var backendRefGroup gatewayv1beta1.Group - var backendRefKind gatewayv1beta1.Kind + var backendRefKind Kind if backendRef.Group != nil { backendRefGroup = *backendRef.Group @@ -341,7 +341,7 @@ func isHTTPReferenceGranted(grantSpec gatewayv1alpha2.ReferenceGrantSpec, backen for _, to := range grantSpec.To { if backendRefGroup == (gatewayv1beta1.Group)(to.Group) && - backendRefKind == (gatewayv1beta1.Kind)(to.Kind) && + backendRefKind == (Kind)(to.Kind) && (to.Name == nil || (gatewayv1beta1.ObjectName)(*to.Name) == backendRef.Name) { return true } diff --git a/internal/controllers/gateway/route_utils_test.go b/internal/controllers/gateway/route_utils_test.go index 68d633cbec..c572fe7845 100644 --- a/internal/controllers/gateway/route_utils_test.go +++ b/internal/controllers/gateway/route_utils_test.go @@ -4,16 +4,15 @@ import ( "testing" "github.com/stretchr/testify/assert" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/kong/kubernetes-ingress-controller/v2/internal/util" ) func Test_filterHostnames(t *testing.T) { - commonGateway := &gatewayv1alpha2.Gateway{ - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{ + commonGateway := &gatewayv1beta1.Gateway{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []Listener{ { Name: "listener-1", Hostname: util.StringToGatewayAPIHostnamePtr("very.specific.com"), diff --git a/internal/controllers/gateway/tcproute_controller.go b/internal/controllers/gateway/tcproute_controller.go index 20d88da030..3d0ee9b81f 100644 --- a/internal/controllers/gateway/tcproute_controller.go +++ b/internal/controllers/gateway/tcproute_controller.go @@ -72,7 +72,7 @@ func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // removed from data-plane configurations, and any routes that are now supported // due to that change get added to data-plane configurations. if err := c.Watch( - &source.Kind{Type: &gatewayv1alpha2.Gateway{}}, + &source.Kind{Type: &gatewayv1beta1.Gateway{}}, handler.EnqueueRequestsFromMapFunc(r.listTCPRoutesForGateway), ); err != nil { return err @@ -108,7 +108,7 @@ func (r *TCPRouteReconciler) listTCPRoutesForGatewayClass(obj client.Object) []r } // map all Gateway objects - gatewayList := gatewayv1alpha2.GatewayList{} + gatewayList := gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), &gatewayList); err != nil { r.Log.Error(err, "failed to list gateway objects from the cached client") return nil @@ -186,7 +186,7 @@ func (r *TCPRouteReconciler) listTCPRoutesForGatewayClass(obj client.Object) []r // this kind of problem without having to enqueue extra objects. func (r *TCPRouteReconciler) listTCPRoutesForGateway(obj client.Object) []reconcile.Request { // verify that the object is a Gateway - gw, ok := obj.(*gatewayv1alpha2.Gateway) + gw, ok := obj.(*gatewayv1beta1.Gateway) if !ok { r.Log.Error(fmt.Errorf("invalid type"), "found invalid type in event handlers", "expected", "Gateway", "found", reflect.TypeOf(obj)) return nil @@ -354,7 +354,11 @@ var tcprouteParentKind = "Gateway" // ensureGatewayReferenceStatus takes any number of Gateways that should be // considered "attached" to a given TCPRoute and ensures that the status // for the TCPRoute is updated appropriately. -func (r *TCPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Context, tcproute *gatewayv1alpha2.TCPRoute, gateways ...supportedGatewayWithCondition) (bool, error) { +func (r *TCPRouteReconciler) ensureGatewayReferenceStatusAdded( + ctx context.Context, + tcproute *gatewayv1alpha2.TCPRoute, + gateways ...supportedGatewayWithCondition, +) (bool, error) { // map the existing parentStatues to avoid duplications parentStatuses := make(map[string]*gatewayv1alpha2.RouteParentStatus) for _, existingParent := range tcproute.Status.Parents { @@ -372,18 +376,18 @@ func (r *TCPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Conte // build a new status for the parent Gateway gatewayParentStatus := &gatewayv1alpha2.RouteParentStatus{ ParentRef: gatewayv1alpha2.ParentReference{ - Group: (*gatewayv1alpha2.Group)(&gatewayv1alpha2.GroupVersion.Group), - Kind: util.StringToGatewayAPIKindPtr(tcprouteParentKind), + Group: (*gatewayv1alpha2.Group)(&gatewayv1beta1.GroupVersion.Group), + Kind: (*gatewayv1alpha2.Kind)(util.StringToGatewayAPIKindPtr(tcprouteParentKind)), Namespace: (*gatewayv1alpha2.Namespace)(&gateway.gateway.Namespace), - Name: gatewayv1alpha2.ObjectName(gateway.gateway.Name), + Name: (gatewayv1alpha2.ObjectName)(gateway.gateway.Name), }, ControllerName: (gatewayv1alpha2.GatewayController)(ControllerName), Conditions: []metav1.Condition{{ - Type: string(gatewayv1alpha2.RouteConditionAccepted), + Type: string(gatewayv1beta1.RouteConditionAccepted), Status: metav1.ConditionTrue, ObservedGeneration: tcproute.Generation, LastTransitionTime: metav1.Now(), - Reason: string(gatewayv1alpha2.RouteReasonAccepted), + Reason: string(gatewayv1beta1.RouteReasonAccepted), }}, } diff --git a/internal/controllers/gateway/tlsroute_controller.go b/internal/controllers/gateway/tlsroute_controller.go index 22c652daf1..30fc6ff829 100644 --- a/internal/controllers/gateway/tlsroute_controller.go +++ b/internal/controllers/gateway/tlsroute_controller.go @@ -72,7 +72,7 @@ func (r *TLSRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // removed from data-plane configurations, and any routes that are now supported // due to that change get added to data-plane configurations. if err := c.Watch( - &source.Kind{Type: &gatewayv1alpha2.Gateway{}}, + &source.Kind{Type: &gatewayv1beta1.Gateway{}}, handler.EnqueueRequestsFromMapFunc(r.listTLSRoutesForGateway), ); err != nil { return err @@ -108,7 +108,7 @@ func (r *TLSRouteReconciler) listTLSRoutesForGatewayClass(obj client.Object) []r } // map all Gateway objects - gatewayList := gatewayv1alpha2.GatewayList{} + gatewayList := gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), &gatewayList); err != nil { r.Log.Error(err, "failed to list gateway objects from the cached client") return nil @@ -186,7 +186,7 @@ func (r *TLSRouteReconciler) listTLSRoutesForGatewayClass(obj client.Object) []r // this kind of problem without having to enqueue extra objects. func (r *TLSRouteReconciler) listTLSRoutesForGateway(obj client.Object) []reconcile.Request { // verify that the object is a Gateway - gw, ok := obj.(*gatewayv1alpha2.Gateway) + gw, ok := obj.(*gatewayv1beta1.Gateway) if !ok { r.Log.Error(fmt.Errorf("invalid type"), "found invalid type in event handlers", "expected", "Gateway", "found", reflect.TypeOf(obj)) return nil @@ -373,7 +373,7 @@ func (r *TLSRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Conte gatewayParentStatus := &gatewayv1alpha2.RouteParentStatus{ ParentRef: gatewayv1alpha2.ParentReference{ Group: (*gatewayv1alpha2.Group)(&gatewayv1alpha2.GroupVersion.Group), - Kind: util.StringToGatewayAPIKindPtr(tlsrouteParentKind), + Kind: (*gatewayv1alpha2.Kind)(util.StringToGatewayAPIKindPtr(tlsrouteParentKind)), Namespace: (*gatewayv1alpha2.Namespace)(&gateway.gateway.Namespace), Name: gatewayv1alpha2.ObjectName(gateway.gateway.Name), }, diff --git a/internal/controllers/gateway/types.go b/internal/controllers/gateway/types.go new file mode 100644 index 0000000000..a1b3a865ce --- /dev/null +++ b/internal/controllers/gateway/types.go @@ -0,0 +1,32 @@ +package gateway + +import ( + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +type ( + Gateway = gatewayv1beta1.Gateway + GatewayAddress = gatewayv1beta1.GatewayAddress + GatewayClass = gatewayv1beta1.GatewayClass + Group = gatewayv1beta1.Group + Hostname = gatewayv1beta1.Hostname + HTTPRoute = gatewayv1beta1.HTTPRoute + Kind = gatewayv1beta1.Kind + Listener = gatewayv1beta1.Listener + ListenerStatus = gatewayv1beta1.ListenerStatus + Namespace = gatewayv1beta1.Namespace + ObjectName = gatewayv1beta1.ObjectName + ParentReference = gatewayv1beta1.ParentReference + RouteParentStatus = gatewayv1beta1.RouteParentStatus + PortNumber = gatewayv1beta1.PortNumber + ProtocolType = gatewayv1beta1.ProtocolType + SectionName = gatewayv1beta1.SectionName +) + +const ( + HTTPProtocolType = gatewayv1beta1.HTTPProtocolType + HTTPSProtocolType = gatewayv1beta1.HTTPSProtocolType + TLSProtocolType = gatewayv1beta1.TLSProtocolType + TCPProtocolType = gatewayv1beta1.TCPProtocolType + UDPProtocolType = gatewayv1beta1.UDPProtocolType +) diff --git a/internal/controllers/gateway/udproute_controller.go b/internal/controllers/gateway/udproute_controller.go index 5c6db4c06e..c5585c517c 100644 --- a/internal/controllers/gateway/udproute_controller.go +++ b/internal/controllers/gateway/udproute_controller.go @@ -72,7 +72,7 @@ func (r *UDPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // removed from data-plane configurations, and any routes that are now supported // due to that change get added to data-plane configurations. if err := c.Watch( - &source.Kind{Type: &gatewayv1alpha2.Gateway{}}, + &source.Kind{Type: &gatewayv1beta1.Gateway{}}, handler.EnqueueRequestsFromMapFunc(r.listUDPRoutesForGateway), ); err != nil { return err @@ -108,7 +108,7 @@ func (r *UDPRouteReconciler) listUDPRoutesForGatewayClass(obj client.Object) []r } // map all Gateway objects - gatewayList := gatewayv1alpha2.GatewayList{} + gatewayList := gatewayv1beta1.GatewayList{} if err := r.Client.List(context.Background(), &gatewayList); err != nil { r.Log.Error(err, "failed to list gateway objects from the cached client") return nil @@ -186,7 +186,7 @@ func (r *UDPRouteReconciler) listUDPRoutesForGatewayClass(obj client.Object) []r // this kind of problem without having to enqueue extra objects. func (r *UDPRouteReconciler) listUDPRoutesForGateway(obj client.Object) []reconcile.Request { // verify that the object is a Gateway - gw, ok := obj.(*gatewayv1alpha2.Gateway) + gw, ok := obj.(*gatewayv1beta1.Gateway) if !ok { r.Log.Error(fmt.Errorf("invalid type"), "found invalid type in event handlers", "expected", "Gateway", "found", reflect.TypeOf(obj)) return nil @@ -373,7 +373,7 @@ func (r *UDPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Conte gatewayParentStatus := &gatewayv1alpha2.RouteParentStatus{ ParentRef: gatewayv1alpha2.ParentReference{ Group: (*gatewayv1alpha2.Group)(&gatewayv1alpha2.GroupVersion.Group), - Kind: util.StringToGatewayAPIKindPtr(udprouteParentKind), + Kind: (*gatewayv1alpha2.Kind)(util.StringToGatewayAPIKindPtr(udprouteParentKind)), Namespace: (*gatewayv1alpha2.Namespace)(&gateway.gateway.Namespace), Name: gatewayv1alpha2.ObjectName(gateway.gateway.Name), }, diff --git a/internal/dataplane/parser/parser.go b/internal/dataplane/parser/parser.go index b39a7d6a43..179602e948 100644 --- a/internal/dataplane/parser/parser.go +++ b/internal/dataplane/parser/parser.go @@ -19,6 +19,7 @@ import ( knative "knative.dev/networking/pkg/apis/networking/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" "github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/kongstate" @@ -411,7 +412,7 @@ func getGatewayCerts(log logrus.FieldLogger, s store.Storer) []certWrapper { return certs } for _, gateway := range gateways { - statuses := make(map[gatewayv1alpha2.SectionName]gatewayv1alpha2.ListenerStatus, len(gateway.Status.Listeners)) + statuses := make(map[gatewayv1beta1.SectionName]gatewayv1beta1.ListenerStatus, len(gateway.Status.Listeners)) for _, status := range gateway.Status.Listeners { statuses[status.Name] = status } diff --git a/internal/dataplane/parser/translate_httproute_test.go b/internal/dataplane/parser/translate_httproute_test.go index d3d256fbfe..b475b9558a 100644 --- a/internal/dataplane/parser/translate_httproute_test.go +++ b/internal/dataplane/parser/translate_httproute_test.go @@ -73,7 +73,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -146,7 +146,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }, @@ -227,7 +227,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -304,7 +304,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }, @@ -374,7 +374,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -414,7 +414,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -491,7 +491,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }, @@ -537,7 +537,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -614,7 +614,7 @@ func Test_ingressRulesFromHTTPRoutes(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName("fake-service"), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }, diff --git a/internal/store/fake_store.go b/internal/store/fake_store.go index 3f31c0d431..0aaf59456c 100644 --- a/internal/store/fake_store.go +++ b/internal/store/fake_store.go @@ -40,7 +40,7 @@ type FakeObjects struct { TCPRoutes []*gatewayv1alpha2.TCPRoute TLSRoutes []*gatewayv1alpha2.TLSRoute ReferenceGrants []*gatewayv1alpha2.ReferenceGrant - Gateways []*gatewayv1alpha2.Gateway + Gateways []*gatewayv1beta1.Gateway TCPIngresses []*configurationv1beta1.TCPIngress UDPIngresses []*configurationv1beta1.UDPIngress IngressClassParametersV1alpha1 []*configurationv1alpha1.IngressClassParameters diff --git a/internal/store/fake_store_test.go b/internal/store/fake_store_test.go index 349f515d90..11d3814884 100644 --- a/internal/store/fake_store_test.go +++ b/internal/store/fake_store_test.go @@ -863,18 +863,18 @@ func TestFakeStoreGateway(t *testing.T) { assert := assert.New(t) require := require.New(t) - grants := []*gatewayv1alpha2.Gateway{ + grants := []*gatewayv1beta1.Gateway{ { ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, - Spec: gatewayv1alpha2.GatewaySpec{}, + Spec: gatewayv1beta1.GatewaySpec{}, }, { ObjectMeta: metav1.ObjectMeta{ Name: "bar", }, - Spec: gatewayv1alpha2.GatewaySpec{}, + Spec: gatewayv1beta1.GatewaySpec{}, }, } store, err := NewFakeStore(FakeObjects{Gateways: grants}) diff --git a/internal/store/store.go b/internal/store/store.go index 82e2d60b02..fe65d17cee 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -91,7 +91,7 @@ type Storer interface { ListTCPRoutes() ([]*gatewayv1alpha2.TCPRoute, error) ListTLSRoutes() ([]*gatewayv1alpha2.TLSRoute, error) ListReferenceGrants() ([]*gatewayv1alpha2.ReferenceGrant, error) - ListGateways() ([]*gatewayv1alpha2.Gateway, error) + ListGateways() ([]*gatewayv1beta1.Gateway, error) ListTCPIngresses() ([]*kongv1beta1.TCPIngress, error) ListUDPIngresses() ([]*kongv1beta1.UDPIngress, error) ListKnativeIngresses() ([]*knative.Ingress, error) @@ -264,7 +264,7 @@ func (c CacheStores) Get(obj runtime.Object) (item interface{}, exists bool, err return c.TLSRoute.Get(obj) case *gatewayv1alpha2.ReferenceGrant: return c.ReferenceGrant.Get(obj) - case *gatewayv1alpha2.Gateway: + case *gatewayv1beta1.Gateway: return c.Gateway.Get(obj) // ---------------------------------------------------------------------------- // Kong API Support @@ -329,7 +329,7 @@ func (c CacheStores) Add(obj runtime.Object) error { return c.TLSRoute.Add(obj) case *gatewayv1alpha2.ReferenceGrant: return c.ReferenceGrant.Add(obj) - case *gatewayv1alpha2.Gateway: + case *gatewayv1beta1.Gateway: return c.Gateway.Add(obj) // ---------------------------------------------------------------------------- // Kong API Support @@ -395,7 +395,7 @@ func (c CacheStores) Delete(obj runtime.Object) error { return c.TLSRoute.Delete(obj) case *gatewayv1alpha2.ReferenceGrant: return c.ReferenceGrant.Delete(obj) - case *gatewayv1alpha2.Gateway: + case *gatewayv1beta1.Gateway: return c.Gateway.Delete(obj) // ---------------------------------------------------------------------------- // Kong API Support @@ -667,11 +667,11 @@ func (s Store) ListReferenceGrants() ([]*gatewayv1alpha2.ReferenceGrant, error) } // ListGateways returns the list of Gateways in the Gateway cache store. -func (s Store) ListGateways() ([]*gatewayv1alpha2.Gateway, error) { - var gateways []*gatewayv1alpha2.Gateway +func (s Store) ListGateways() ([]*gatewayv1beta1.Gateway, error) { + var gateways []*gatewayv1beta1.Gateway if err := cache.ListAll(s.stores.Gateway, labels.NewSelector(), func(ob interface{}) { - gw, ok := ob.(*gatewayv1alpha2.Gateway) + gw, ok := ob.(*gatewayv1beta1.Gateway) if ok { gateways = append(gateways, gw) } diff --git a/internal/types/types.go b/internal/types/types.go index 913a594938..016bf09b03 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -28,5 +28,5 @@ type ParentReferenceT interface { } type BackendRefT interface { - gatewayv1beta1.BackendRef | gatewayv1alpha2.BackendRef | gatewayv1alpha2.SecretObjectReference + gatewayv1beta1.BackendRef | gatewayv1alpha2.BackendRef | gatewayv1beta1.SecretObjectReference } diff --git a/internal/util/conversions.go b/internal/util/conversions.go index 4e2c6b3f76..a490f6d478 100644 --- a/internal/util/conversions.go +++ b/internal/util/conversions.go @@ -20,9 +20,9 @@ func StringToGatewayAPIHostnameV1Beta1(hostname string) gatewayv1beta1.Hostname return (gatewayv1beta1.Hostname)(hostname) } -// StringToGatewayAPIHostnamePtr converts a string to a *gatewayv1alpha2.Hostname. -func StringToGatewayAPIHostnamePtr(hostname string) *gatewayv1alpha2.Hostname { - return (*gatewayv1alpha2.Hostname)(pointer.StringPtr(hostname)) +// StringToGatewayAPIHostnamePtr converts a string to a *gatewayv1beta1.Hostname. +func StringToGatewayAPIHostnamePtr(hostname string) *gatewayv1beta1.Hostname { + return (*gatewayv1beta1.Hostname)(pointer.StringPtr(hostname)) } // StringToGatewayAPIHostnameV1Beta1Ptr converts a string to a *gatewayv1beta1.Hostname. @@ -35,12 +35,7 @@ func StringToGatewayAPIKind(kind string) gatewayv1alpha2.Kind { return (gatewayv1alpha2.Kind)(kind) } -// StringToGatewayAPIKindPtr converts a string to a *gatewayv1alpha2.Kind. -func StringToGatewayAPIKindPtr(kind string) *gatewayv1alpha2.Kind { - return (*gatewayv1alpha2.Kind)(pointer.StringPtr(kind)) -} - -// StringToGatewayAPIKindV1Beta1Ptr converts a string to a *gatewayv1beta1.Kind. -func StringToGatewayAPIKindV1Beta1Ptr(kind string) *gatewayv1beta1.Kind { +// StringToGatewayAPIKindPtr converts a string to a *gatewayv1beta1.Kind. +func StringToGatewayAPIKindPtr(kind string) *gatewayv1beta1.Kind { return (*gatewayv1beta1.Kind)(pointer.StringPtr(kind)) } diff --git a/internal/validation/gateway/httproute.go b/internal/validation/gateway/httproute.go index fd2537b665..bd76d8480b 100644 --- a/internal/validation/gateway/httproute.go +++ b/internal/validation/gateway/httproute.go @@ -3,7 +3,6 @@ package gateway import ( "fmt" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) @@ -14,7 +13,7 @@ import ( // ValidateHTTPRoute provides a suite of validation for a given HTTPRoute and // any number of Gateway resources it's attached to that the caller wants to // have it validated against. -func ValidateHTTPRoute(httproute *gatewayv1beta1.HTTPRoute, attachedGateways ...*gatewayv1alpha2.Gateway) (bool, string, error) { +func ValidateHTTPRoute(httproute *gatewayv1beta1.HTTPRoute, attachedGateways ...*gatewayv1beta1.Gateway) (bool, string, error) { // perform Gateway validations for the HTTPRoute (e.g. listener validation, namespace validation, e.t.c.) for _, gateway := range attachedGateways { // TODO: validate that the namespace is supported by the linked Gateway objects @@ -54,7 +53,7 @@ func ValidateHTTPRoute(httproute *gatewayv1beta1.HTTPRoute, attachedGateways ... // validateHTTPRouteListener verifies that a given HTTPRoute is configured properly // for a given gateway listener which it is linked to. -func validateHTTPRouteListener(listener *gatewayv1alpha2.Listener) error { +func validateHTTPRouteListener(listener *gatewayv1beta1.Listener) error { // verify that the listener supports HTTPRoute objects if listener.AllowedRoutes != nil && // if there are no allowed routes, assume all are allowed len(listener.AllowedRoutes.Kinds) > 0 { // if there are no allowed kinds, assume all are allowed @@ -123,7 +122,7 @@ func validateHTTPRouteFeatures(httproute *gatewayv1beta1.HTTPRoute) error { // which links to the provided Gateway if available. If the provided Gateway is not // actually referenced by parentRef in the provided HTTPRoute this is considered // invalid input and will produce an error. -func getParentRefForHTTPRouteGateway(httproute *gatewayv1beta1.HTTPRoute, gateway *gatewayv1alpha2.Gateway) (*gatewayv1beta1.ParentReference, error) { +func getParentRefForHTTPRouteGateway(httproute *gatewayv1beta1.HTTPRoute, gateway *gatewayv1beta1.Gateway) (*gatewayv1beta1.ParentReference, error) { // search all the parentRefs on the HTTPRoute to find one that matches the Gateway for _, ref := range httproute.Spec.ParentRefs { // determine the namespace for the gateway reference @@ -145,8 +144,8 @@ func getParentRefForHTTPRouteGateway(httproute *gatewayv1beta1.HTTPRoute, gatewa // getListenersForHTTPRouteValidation determines if ALL http listeners should be used for validation // or if only a select listener should be considered. -func getListenersForHTTPRouteValidation(sectionName *gatewayv1beta1.SectionName, gateway *gatewayv1alpha2.Gateway) ([]*gatewayv1alpha2.Listener, error) { - var listenersForValidation []*gatewayv1alpha2.Listener +func getListenersForHTTPRouteValidation(sectionName *gatewayv1beta1.SectionName, gateway *gatewayv1beta1.Gateway) ([]*gatewayv1beta1.Listener, error) { + var listenersForValidation []*gatewayv1beta1.Listener if sectionName != nil { // only one specified listener is in use, only need to validate the // route against that listener. diff --git a/internal/validation/gateway/httproute_test.go b/internal/validation/gateway/httproute_test.go index 31e728010a..e19c9da33c 100644 --- a/internal/validation/gateway/httproute_test.go +++ b/internal/validation/gateway/httproute_test.go @@ -8,14 +8,13 @@ import ( "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) func TestValidateHTTPRoute(t *testing.T) { var ( nonexistentListener = gatewayv1beta1.SectionName("listener-that-doesnt-exist") - group = gatewayv1alpha2.Group("gateway.networking.k8s.io") + group = gatewayv1beta1.Group("gateway.networking.k8s.io") defaultGWNamespace = gatewayv1beta1.Namespace(corev1.NamespaceDefault) pathMatchRegex = gatewayv1beta1.PathMatchRegularExpression headerMatchRegex = gatewayv1beta1.HeaderMatchRegularExpression @@ -26,7 +25,7 @@ func TestValidateHTTPRoute(t *testing.T) { for _, tt := range []struct { msg string route *gatewayv1beta1.HTTPRoute - gateways []*gatewayv1alpha2.Gateway + gateways []*gatewayv1beta1.Gateway valid bool validationMsg string err error @@ -39,18 +38,18 @@ func TestValidateHTTPRoute(t *testing.T) { Name: "testing-httproute", }, }, // no parentRefs - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -78,18 +77,18 @@ func TestValidateHTTPRoute(t *testing.T) { }, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "not-the-right-listener", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -116,13 +115,13 @@ func TestValidateHTTPRoute(t *testing.T) { }, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{}, + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{}, }, }}, valid: false, @@ -144,18 +143,18 @@ func TestValidateHTTPRoute(t *testing.T) { }, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -180,18 +179,18 @@ func TestValidateHTTPRoute(t *testing.T) { }, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http-alternate", Port: 8000, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "TCPRoute", }}, @@ -233,18 +232,18 @@ func TestValidateHTTPRoute(t *testing.T) { }}, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -286,18 +285,18 @@ func TestValidateHTTPRoute(t *testing.T) { }}, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -340,18 +339,18 @@ func TestValidateHTTPRoute(t *testing.T) { }}, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -398,18 +397,18 @@ func TestValidateHTTPRoute(t *testing.T) { }}, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, @@ -455,18 +454,18 @@ func TestValidateHTTPRoute(t *testing.T) { }}, }, }, - gateways: []*gatewayv1alpha2.Gateway{{ + gateways: []*gatewayv1beta1.Gateway{{ ObjectMeta: metav1.ObjectMeta{ Namespace: corev1.NamespaceDefault, Name: "testing-gateway", }, - Spec: gatewayv1alpha2.GatewaySpec{ - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + Listeners: []gatewayv1beta1.Listener{{ Name: "http", Port: 80, - Protocol: (gatewayv1alpha2.ProtocolType)(gatewayv1beta1.HTTPProtocolType), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Kinds: []gatewayv1alpha2.RouteGroupKind{{ + Protocol: (gatewayv1beta1.ProtocolType)(gatewayv1beta1.HTTPProtocolType), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Kinds: []gatewayv1beta1.RouteGroupKind{{ Group: &group, Kind: "HTTPRoute", }}, diff --git a/test/e2e/features_test.go b/test/e2e/features_test.go index 81cc082026..ebb67c7766 100644 --- a/test/e2e/features_test.go +++ b/test/e2e/features_test.go @@ -25,6 +25,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" "github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" @@ -377,26 +378,26 @@ func TestDeployAllInOneDBLESSGateway(t *testing.T) { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) gw.Spec.Listeners = append(gw.Spec.Listeners, - gatewayv1alpha2.Listener{ + gatewayv1beta1.Listener{ Name: "badhttp", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(9999), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(9999), }, - gatewayv1alpha2.Listener{ + gatewayv1beta1.Listener{ Name: "badudp", - Protocol: gatewayv1alpha2.UDPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.UDPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }, ) t.Log("verifying that unsupported listeners indicate correct status") - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Update(ctx, gw, metav1.UpdateOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Update(ctx, gw, metav1.UpdateOptions{}) require.NoError(t, err) require.Eventually(t, func() bool { - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) var http, udp bool for _, lstatus := range gw.Status.Listeners { if lstatus.Name == "badhttp" { @@ -427,7 +428,7 @@ func TestDeployAllInOneDBLESSGateway(t *testing.T) { return http == udp == true }, time.Minute*2, time.Second*5) - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) t.Logf("deploying Gateway APIs CRDs in experimental channel from %s", consts.GatewayExperimentalCRDsKustomizeURL) diff --git a/test/e2e/helpers_gateway_test.go b/test/e2e/helpers_gateway_test.go index d02025e662..38f50d2a90 100644 --- a/test/e2e/helpers_gateway_test.go +++ b/test/e2e/helpers_gateway_test.go @@ -32,7 +32,7 @@ import ( ) // deployGateway deploys a gateway with a new created gateway class and a fixed name `kong`. -func deployGateway(ctx context.Context, t *testing.T, env environments.Environment) *gatewayv1alpha2.Gateway { +func deployGateway(ctx context.Context, t *testing.T, env environments.Environment) *gatewayv1beta1.Gateway { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) @@ -49,38 +49,38 @@ func deployGateway(ctx context.Context, t *testing.T, env environments.Environme require.NoError(t, err) t.Log("deploying a gateway to the test cluster using unmanaged gateway mode") - gw := &gatewayv1alpha2.Gateway{ + gw := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "kong", Annotations: map[string]string{ annotations.AnnotationPrefix + annotations.GatewayUnmanagedAnnotation: "true", // trigger the unmanaged gateway mode }, }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(supportedGatewayClass.Name), - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(supportedGatewayClass.Name), + Listeners: []gatewayv1beta1.Listener{{ Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }}, }, } - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) require.NoError(t, err) return gw } // verifyGateway verifies that the gateway `gw` is ready. -func verifyGateway(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1alpha2.Gateway) { +func verifyGateway(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1beta1.Gateway) { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) t.Log("verifying that the gateway receives a final ready condition once reconciliation completes") require.Eventually(t, func() bool { - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) for _, cond := range gw.Status.Conditions { - if cond.Reason == string(gatewayv1alpha2.GatewayReasonReady) { + if cond.Reason == string(gatewayv1beta1.GatewayReasonReady) { return true } } @@ -89,7 +89,7 @@ func verifyGateway(ctx context.Context, t *testing.T, env environments.Environme } // deployGatewayWithTCPListener deploys a gateway `kong` with a tcp listener to test TCPRoute. -func deployGatewayWithTCPListener(ctx context.Context, t *testing.T, env environments.Environment) *gatewayv1alpha2.Gateway { +func deployGatewayWithTCPListener(ctx context.Context, t *testing.T, env environments.Environment) *gatewayv1beta1.Gateway { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) @@ -106,36 +106,36 @@ func deployGatewayWithTCPListener(ctx context.Context, t *testing.T, env environ require.NoError(t, err) t.Log("deploying a gateway to the test cluster using unmanaged gateway mode") - gw := &gatewayv1alpha2.Gateway{ + gw := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "kong", }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(supportedGatewayClass.Name), - Listeners: []gatewayv1alpha2.Listener{ + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(supportedGatewayClass.Name), + Listeners: []gatewayv1beta1.Listener{ { Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }, { Name: "tcp", - Protocol: gatewayv1alpha2.TCPProtocolType, - Port: gatewayv1alpha2.PortNumber(tcpListnerPort), + Protocol: gatewayv1beta1.TCPProtocolType, + Port: gatewayv1beta1.PortNumber(tcpListnerPort), }, }, }, } - _, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) + _, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, gw.Name, metav1.GetOptions{}) if err == nil { t.Logf("gateway %s exists, delete and re-create it", gw.Name) - err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Delete(ctx, gw.Name, metav1.DeleteOptions{}) + err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Delete(ctx, gw.Name, metav1.DeleteOptions{}) require.NoError(t, err) - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) require.NoError(t, err) } else { require.True(t, kerrors.IsNotFound(err)) - gw, err = gc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) + gw, err = gc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Create(ctx, gw, metav1.CreateOptions{}) require.NoError(t, err) } return gw @@ -143,7 +143,7 @@ func deployGatewayWithTCPListener(ctx context.Context, t *testing.T, env environ // deployHTTPRoute creates an `HTTPRoute` and related backend deployment/service. // it matches the specified path `/httpbin` by prefix, so we can access the backend service by `http://$PROXY_IP/httpbin`. -func deployHTTPRoute(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1alpha2.Gateway) { +func deployHTTPRoute(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1beta1.Gateway) { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) t.Log("deploying an HTTP service to test the ingress controller and proxy") @@ -225,7 +225,7 @@ func verifyHTTPRoute(ctx context.Context, t *testing.T, env environments.Environ } // deployTCPRoute creates a `TCPRoute` and related backend deployment/service. -func deployTCPRoute(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1alpha2.Gateway) { +func deployTCPRoute(ctx context.Context, t *testing.T, env environments.Environment, gw *gatewayv1beta1.Gateway) { gc, err := gatewayclient.NewForConfig(env.Cluster().Config()) require.NoError(t, err) t.Log("deploying a TCP service to test the ingress controller and proxy") diff --git a/test/integration/examples_test.go b/test/integration/examples_test.go index 92956ef67e..776a544edb 100644 --- a/test/integration/examples_test.go +++ b/test/integration/examples_test.go @@ -22,6 +22,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" "github.com/kong/kubernetes-ingress-controller/v2/test" @@ -55,13 +56,13 @@ func TestHTTPRouteExample(t *testing.T) { t.Logf("verifying that the Gateway receives listen addresses") var gatewayAddr string require.Eventually(t, func() bool { - obj, err := gwc.GatewayV1alpha2().Gateways(corev1.NamespaceDefault).Get(ctx, "kong", metav1.GetOptions{}) + obj, err := gwc.GatewayV1beta1().Gateways(corev1.NamespaceDefault).Get(ctx, "kong", metav1.GetOptions{}) if err != nil { return false } for _, addr := range obj.Status.Addresses { - if addr.Type != nil && *addr.Type == gatewayv1alpha2.IPAddressType { + if addr.Type != nil && *addr.Type == (gatewayv1beta1.AddressType)(gatewayv1alpha2.IPAddressType) { gatewayAddr = addr.Value return true } diff --git a/test/integration/gateway_test.go b/test/integration/gateway_test.go index 4db296867a..579484340d 100644 --- a/test/integration/gateway_test.go +++ b/test/integration/gateway_test.go @@ -38,7 +38,7 @@ const ( ) func TestUnmanagedGatewayBasics(t *testing.T) { - var gw *gatewayv1alpha2.Gateway + var gw *gatewayv1beta1.Gateway ns, cleaner := setup(t) defer func() { assert.NoError(t, cleaner.Cleanup(ctx)) }() @@ -58,14 +58,14 @@ func TestUnmanagedGatewayBasics(t *testing.T) { t.Log("verifying that the gateway service ref gets provisioned when placeholder is used") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, defaultGatewayName, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, defaultGatewayName, metav1.GetOptions{}) require.NoError(t, err) return gw.Annotations[unmanagedAnnotation] == "kong-system/ingress-controller-kong-proxy" }, gatewayUpdateWaitTime, time.Second) t.Log("verifying that the gateway address is populated from the publish service") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) if len(gw.Spec.Addresses) == len(pubsvc.Status.LoadBalancer.Ingress) { addrs := make(map[string]bool, len(pubsvc.Status.LoadBalancer.Ingress)) @@ -88,19 +88,19 @@ func TestUnmanagedGatewayBasics(t *testing.T) { t.Log("verifying that the gateway status gets updated to match the publish service") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) return len(gw.Status.Listeners) == len(gw.Spec.Listeners) && len(gw.Status.Addresses) == len(gw.Spec.Addresses) }, gatewayUpdateWaitTime, time.Second) t.Log("verifying that the gateway receives a final ready condition once reconciliation completes") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) // The conditions should be snapshots, so we judge by the observed status of condition with type Ready. for _, cond := range gw.Status.Conditions { - if cond.Type == string(gatewayv1alpha2.GatewayConditionReady) { - return cond.Reason == string(gatewayv1alpha2.GatewayReasonReady) + if cond.Type == string(gatewayv1beta1.GatewayConditionReady) { + return cond.Reason == string(gatewayv1beta1.GatewayReasonReady) } } return false @@ -108,7 +108,7 @@ func TestUnmanagedGatewayBasics(t *testing.T) { t.Log("verifying that the gateway listeners reach the ready condition") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) for _, lstatus := range gw.Status.Listeners { // we may have several conditions but only care about one, so loop through each and mark ready only if @@ -128,7 +128,7 @@ func TestUnmanagedGatewayBasics(t *testing.T) { } func TestGatewayListenerConflicts(t *testing.T) { - var gw *gatewayv1alpha2.Gateway + var gw *gatewayv1beta1.Gateway ns, cleaner := setup(t) defer func() { assert.NoError(t, cleaner.Cleanup(ctx)) }() @@ -146,7 +146,7 @@ func TestGatewayListenerConflicts(t *testing.T) { t.Log("verifying that the gateway listeners reach the ready condition") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, defaultGatewayName, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, defaultGatewayName, metav1.GetOptions{}) require.NoError(t, err) for _, lstatus := range gw.Status.Listeners { // we may have several conditions but only care about one, so loop through each and mark ready only if @@ -166,26 +166,26 @@ func TestGatewayListenerConflicts(t *testing.T) { t.Log("adding conflicting listeners") gw.Spec.Listeners = append(gw.Spec.Listeners, - gatewayv1alpha2.Listener{ + gatewayv1beta1.Listener{ Name: "badhttp", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }, - gatewayv1alpha2.Listener{ + gatewayv1beta1.Listener{ Name: "badudp", - Protocol: gatewayv1alpha2.UDPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.UDPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }, ) - _, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) + _, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) require.NoError(t, err) - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) t.Log("confirming existing listen becomes unready and conflicted, new HTTP listen has hostname conflict, new UDP listen has proto conflict") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) var badhttpReady, badhttpConflicted, badudpReady, badudpConflicted, httpReady, httpConflicted bool for _, lstatus := range gw.Status.Listeners { @@ -228,25 +228,25 @@ func TestGatewayListenerConflicts(t *testing.T) { t.Log("changing listeners to a set with conflicting hostnames") // these both use the empty hostname - gw.Spec.Listeners = []gatewayv1alpha2.Listener{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "httpsalpha", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), }, { Name: "httpsbravo", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), }, } - _, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) + _, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) require.NoError(t, err) t.Log("confirming listeners with conflicted hostnames receive appropriate conditions") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) var httpAlphaReady, httpAlphaConflicted, httpBravoReady, httpBravoConflicted bool for _, lstatus := range gw.Status.Listeners { @@ -274,49 +274,49 @@ func TestGatewayListenerConflicts(t *testing.T) { return !httpAlphaReady && httpAlphaConflicted && !httpBravoReady && httpBravoConflicted }, gatewayUpdateWaitTime, time.Second) t.Log("swapping out existing listeners with multiple compatible listeners") - tlsHost := gatewayv1alpha2.Hostname("tls.example") - httpsHost := gatewayv1alpha2.Hostname("https.example") - httphostHost := gatewayv1alpha2.Hostname("http.example") + tlsHost := gatewayv1beta1.Hostname("tls.example") + httpsHost := gatewayv1beta1.Hostname("https.example") + httphostHost := gatewayv1beta1.Hostname("http.example") // this tests compatibility to the extent that we can with Kong listens. it does not support the full range // of compatible Gateway Routes. Gateway permits TLS and HTTPS routes to coexist on the same port so long // as all use unique hostnames. Kong, however, requires that TLS routes go through a TLS stream listen, so // the binds are separate and we cannot combine them. attempting to do so (e.g. setting the tls port to 443 here) // will result in ListenerReasonPortUnavailable - gw.Spec.Listeners = []gatewayv1alpha2.Listener{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }, { Name: "tls", - Protocol: gatewayv1alpha2.TLSProtocolType, - Port: gatewayv1alpha2.PortNumber(8899), + Protocol: gatewayv1beta1.TLSProtocolType, + Port: gatewayv1beta1.PortNumber(8899), Hostname: &tlsHost, }, { Name: "https", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), Hostname: &httpsHost, }, { Name: "httphost", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), Hostname: &httphostHost, }, } - _, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) + _, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Update(ctx, gw, metav1.UpdateOptions{}) require.NoError(t, err) - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) t.Log("confirming existing listen remains ready and new listens become ready") require.Eventually(t, func() bool { - gw, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) + gw, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gw.Name, metav1.GetOptions{}) require.NoError(t, err) var httpReady, tlsReady, httpsReady, httphostReady bool for _, lstatus := range gw.Status.Listeners { @@ -376,10 +376,10 @@ func TestUnmanagedGatewayControllerSupport(t *testing.T) { t.Log("verifying that the unsupported Gateway object does not get scheduled by the controller") timeout := time.Now().Add(gatewayWaitTimeToVerifyScheduling) for timeout.After(time.Now()) { - unsupportedGateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, unsupportedGateway.Name, metav1.GetOptions{}) + unsupportedGateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, unsupportedGateway.Name, metav1.GetOptions{}) require.NoError(t, err) require.Len(t, unsupportedGateway.Status.Conditions, 1) - require.Equal(t, string(gatewayv1alpha2.GatewayReasonNotReconciled), unsupportedGateway.Status.Conditions[0].Reason) + require.Equal(t, string(gatewayv1beta1.GatewayReasonNotReconciled), unsupportedGateway.Status.Conditions[0].Reason) } } @@ -394,7 +394,7 @@ func TestUnmanagedGatewayClass(t *testing.T) { t.Log("deploying a gateway to the test cluster using unmanaged mode, but with no valid gatewayclass yet") gatewayClassName := uuid.NewString() gatewayName := uuid.NewString() - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName }) require.NoError(t, err) @@ -403,10 +403,10 @@ func TestUnmanagedGatewayClass(t *testing.T) { t.Log("verifying that the Gateway object does not get scheduled by the controller due to missing its GatewayClass") timeout := time.Now().Add(gatewayWaitTimeToVerifyScheduling) for timeout.After(time.Now()) { - gateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) + gateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) require.NoError(t, err) require.Len(t, gateway.Status.Conditions, 1) - require.Equal(t, string(gatewayv1alpha2.GatewayReasonNotReconciled), gateway.Status.Conditions[0].Reason) + require.Equal(t, string(gatewayv1beta1.GatewayReasonNotReconciled), gateway.Status.Conditions[0].Reason) } t.Log("deploying the missing gatewayclass to the test cluster") @@ -416,10 +416,10 @@ func TestUnmanagedGatewayClass(t *testing.T) { t.Log("now that the gatewayclass exists, verifying that the gateway resource gets resolved") require.Eventually(t, func() bool { - gateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) + gateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) require.NoError(t, err) for _, cond := range gateway.Status.Conditions { - if cond.Reason == string(gatewayv1alpha2.GatewayReasonReady) { + if cond.Reason == string(gatewayv1beta1.GatewayReasonReady) { return true } } @@ -443,26 +443,26 @@ func TestGatewayFilters(t *testing.T) { t.Log("deploying a gateway that allows routes in all namespaces") gatewayName := uuid.NewString() - fromAll := gatewayv1alpha2.NamespacesFromAll - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + fromAll := gatewayv1beta1.NamespacesFromAll + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromAll, }, }, }, { Name: "https", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromAll, }, }, @@ -516,7 +516,7 @@ func TestGatewayFilters(t *testing.T) { }() t.Logf("creating an httproute to access deployment %s via kong", deployment.Name) - httpPort := gatewayv1alpha2.PortNumber(80) + httpPort := gatewayv1beta1.PortNumber(80) pathMatchPrefix := gatewayv1alpha2.PathMatchPathPrefix refNamespace := gatewayv1alpha2.Namespace(gateway.Namespace) httprouteTemplate := &gatewayv1beta1.HTTPRoute{ @@ -577,7 +577,7 @@ func TestGatewayFilters(t *testing.T) { }() t.Log("verifying that the Gateway gets linked to the route via status") - callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("waiting for routes from HTTPRoute to become operational") @@ -586,32 +586,32 @@ func TestGatewayFilters(t *testing.T) { eventuallyGETPath(t, "other_test_gateway_filters", http.StatusOK, "httpbin.org", emptyHeaderSet) t.Log("changing to the same namespace filter") - gateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) + gateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) require.NoError(t, err) - fromSame := gatewayv1alpha2.NamespacesFromSame - gateway.Spec.Listeners = []gatewayv1alpha2.Listener{ + fromSame := gatewayv1beta1.NamespacesFromSame + gateway.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromSame, }, }, }, { Name: "https", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromSame, }, }, }, } - _, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Update(ctx, gateway, metav1.UpdateOptions{}) + _, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Update(ctx, gateway, metav1.UpdateOptions{}) require.NoError(t, err) t.Log("confirming other namespace route becomes inaccessible") @@ -620,16 +620,16 @@ func TestGatewayFilters(t *testing.T) { eventuallyGETPath(t, "test_gateway_filters", http.StatusOK, "httpbin.org", emptyHeaderSet) t.Log("changing to a selector filter") - gateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) + gateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) require.NoError(t, err) - fromSelector := gatewayv1alpha2.NamespacesFromSelector - gateway.Spec.Listeners = []gatewayv1alpha2.Listener{ + fromSelector := gatewayv1beta1.NamespacesFromSelector + gateway.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromSelector, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ @@ -641,10 +641,10 @@ func TestGatewayFilters(t *testing.T) { }, { Name: "https", - Protocol: gatewayv1alpha2.HTTPSProtocolType, - Port: gatewayv1alpha2.PortNumber(443), - AllowedRoutes: &gatewayv1alpha2.AllowedRoutes{ - Namespaces: &gatewayv1alpha2.RouteNamespaces{ + Protocol: gatewayv1beta1.HTTPSProtocolType, + Port: gatewayv1beta1.PortNumber(443), + AllowedRoutes: &gatewayv1beta1.AllowedRoutes{ + Namespaces: &gatewayv1beta1.RouteNamespaces{ From: &fromSelector, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ @@ -656,7 +656,7 @@ func TestGatewayFilters(t *testing.T) { }, } - _, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Update(ctx, gateway, metav1.UpdateOptions{}) + _, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Update(ctx, gateway, metav1.UpdateOptions{}) require.NoError(t, err) t.Log("confirming wrong selector namespace route becomes inaccessible") diff --git a/test/integration/gateway_webhook_test.go b/test/integration/gateway_webhook_test.go index 64a80ae483..d5279b2313 100644 --- a/test/integration/gateway_webhook_test.go +++ b/test/integration/gateway_webhook_test.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" "github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" @@ -55,7 +55,7 @@ func TestGatewayValidationWebhook(t *testing.T) { for _, tt := range []struct { name string - createdGW gatewayv1alpha2.Gateway + createdGW gatewayv1beta1.Gateway patch []byte // optional wantCreateErr bool @@ -66,19 +66,19 @@ func TestGatewayValidationWebhook(t *testing.T) { }{ { name: "valid gateway", - createdGW: gatewayv1alpha2.Gateway{ + createdGW: gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: uuid.NewString(), Annotations: map[string]string{ annotations.AnnotationPrefix + annotations.GatewayUnmanagedAnnotation: "true", }, }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(managedGatewayClassName), - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(managedGatewayClassName), + Listeners: []gatewayv1beta1.Listener{{ Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(80), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(80), }}, }, }, @@ -86,7 +86,7 @@ func TestGatewayValidationWebhook(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - _, gotCreateErr := gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Create(ctx, &tt.createdGW, metav1.CreateOptions{}) + _, gotCreateErr := gatewayClient.GatewayV1beta1().Gateways(ns.Name).Create(ctx, &tt.createdGW, metav1.CreateOptions{}) if tt.wantCreateErr { require.Error(t, gotCreateErr) require.Contains(t, gotCreateErr.Error(), tt.wantCreateErrSubstring) @@ -95,7 +95,7 @@ func TestGatewayValidationWebhook(t *testing.T) { } if len(tt.patch) > 0 { - _, gotUpdateErr := gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Patch(ctx, tt.createdGW.Name, types.MergePatchType, tt.patch, metav1.PatchOptions{}) + _, gotUpdateErr := gatewayClient.GatewayV1beta1().Gateways(ns.Name).Patch(ctx, tt.createdGW.Name, types.MergePatchType, tt.patch, metav1.PatchOptions{}) if tt.wantPatchErr { require.Error(t, gotUpdateErr) require.Contains(t, gotUpdateErr.Error(), tt.wantPatchErrSubstring) @@ -104,7 +104,7 @@ func TestGatewayValidationWebhook(t *testing.T) { } } - if err := gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, tt.createdGW.Name, metav1.DeleteOptions{}); err != nil && !errors.IsNotFound(err) { + if err := gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, tt.createdGW.Name, metav1.DeleteOptions{}); err != nil && !errors.IsNotFound(err) { require.NoError(t, err) } }) diff --git a/test/integration/helpers_test.go b/test/integration/helpers_test.go index 407522d91e..81b0dea17e 100644 --- a/test/integration/helpers_test.go +++ b/test/integration/helpers_test.go @@ -30,7 +30,7 @@ const ( managedGatewayClassName = "kong-managed" // unmanagedControllerName is the name of the controller used for those gateways that are not supported // by an actual controller (i.e., they won't be scheduled). - unmanagedControllerName gatewayv1alpha2.GatewayController = "example.com/unmanaged-gateway-controller" + unmanagedControllerName gatewayv1beta1.GatewayController = "example.com/unmanaged-gateway-controller" ) // DeployGateway creates a default gatewayClass, accepts a variadic set of options, @@ -62,21 +62,21 @@ func DeployGatewayClass(ctx context.Context, client *gatewayclient.Clientset, ga // DeployGateway creates a default gateway, accepts a variadic set of options, // and finally deploys it on the Kubernetes cluster by means of the gateway client given as arg. -func DeployGateway(ctx context.Context, client *gatewayclient.Clientset, namespace, gatewayClassName string, opts ...func(*gatewayv1alpha2.Gateway)) (*gatewayv1alpha2.Gateway, error) { +func DeployGateway(ctx context.Context, client *gatewayclient.Clientset, namespace, gatewayClassName string, opts ...func(*gatewayv1beta1.Gateway)) (*gatewayv1beta1.Gateway, error) { // create a default gateway with a listener set to port 80 for HTTP traffic - gw := &gatewayv1alpha2.Gateway{ + gw := &gatewayv1beta1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: defaultGatewayName, Annotations: map[string]string{ unmanagedAnnotation: "true", // trigger the unmanaged gateway mode }, }, - Spec: gatewayv1alpha2.GatewaySpec{ - GatewayClassName: gatewayv1alpha2.ObjectName(gatewayClassName), - Listeners: []gatewayv1alpha2.Listener{{ + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName(gatewayClassName), + Listeners: []gatewayv1beta1.Listener{{ Name: "http", - Protocol: gatewayv1alpha2.HTTPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultProxyTCPServicePort), + Protocol: gatewayv1beta1.HTTPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultProxyTCPServicePort), }}, }, } @@ -86,13 +86,13 @@ func DeployGateway(ctx context.Context, client *gatewayclient.Clientset, namespa opt(gw) } - result, err := client.GatewayV1alpha2().Gateways(namespace).Create(ctx, gw, metav1.CreateOptions{}) + result, err := client.GatewayV1beta1().Gateways(namespace).Create(ctx, gw, metav1.CreateOptions{}) if apierrors.IsAlreadyExists(err) { - err = client.GatewayV1alpha2().Gateways(namespace).Delete(ctx, gw.Name, metav1.DeleteOptions{}) + err = client.GatewayV1beta1().Gateways(namespace).Delete(ctx, gw.Name, metav1.DeleteOptions{}) if err != nil { return result, err } - result, err = client.GatewayV1alpha2().Gateways(namespace).Create(ctx, gw, metav1.CreateOptions{}) + result, err = client.GatewayV1beta1().Gateways(namespace).Create(ctx, gw, metav1.CreateOptions{}) } return result, err } @@ -117,10 +117,10 @@ func gatewayHealthCheck(ctx context.Context, client *gatewayclient.Clientset, ga case <-tick: tick = nil ch <- func() bool { - gw, err := client.GatewayV1alpha2().Gateways(namespace).Get(ctx, gatewayName, metav1.GetOptions{}) + gw, err := client.GatewayV1beta1().Gateways(namespace).Get(ctx, gatewayName, metav1.GetOptions{}) exitOnErr(err) for _, cond := range gw.Status.Conditions { - if cond.Reason == string(gatewayv1alpha2.GatewayReasonReady) { + if cond.Reason == string(gatewayv1beta1.GatewayReasonReady) { return true } } @@ -137,7 +137,7 @@ func gatewayHealthCheck(ctx context.Context, client *gatewayclient.Clientset, ga // GetGatewayIsLinkedCallback returns a callback that checks if the specific Route (HTTP, TCP, TLS, or UDP) // is correctly linked to a supported gateway. -func GetGatewayIsLinkedCallback(t *testing.T, c *gatewayclient.Clientset, protocolType gatewayv1alpha2.ProtocolType, namespace, name string) func() bool { +func GetGatewayIsLinkedCallback(t *testing.T, c *gatewayclient.Clientset, protocolType gatewayv1beta1.ProtocolType, namespace, name string) func() bool { return func() bool { return gatewayLinkStatusMatches(t, c, true, protocolType, namespace, name) } @@ -145,7 +145,7 @@ func GetGatewayIsLinkedCallback(t *testing.T, c *gatewayclient.Clientset, protoc // GetGatewayIsUnlinkedCallback returns a callback that checks if the specific Route (HTTP, TCP, TLS, or UDP) // is correctly unlinked from a supported gateway. -func GetGatewayIsUnlinkedCallback(t *testing.T, c *gatewayclient.Clientset, protocolType gatewayv1alpha2.ProtocolType, namespace, name string) func() bool { +func GetGatewayIsUnlinkedCallback(t *testing.T, c *gatewayclient.Clientset, protocolType gatewayv1beta1.ProtocolType, namespace, name string) func() bool { return func() bool { return gatewayLinkStatusMatches(t, c, false, protocolType, namespace, name) } @@ -192,10 +192,16 @@ func (rp routeParents[T]) check(verifyLinked bool, controllerName string) bool { // is correctly linked to (or unlinked from) a supported gateway. In order to assert // that the route must be linked to the gateway, or unlinked from the gateway, the // verifyLinked boolean arg must be set accordingly. -func gatewayLinkStatusMatches(t *testing.T, c *gatewayclient.Clientset, verifyLinked bool, protocolType gatewayv1alpha2.ProtocolType, namespace, name string) bool { +func gatewayLinkStatusMatches( + t *testing.T, + c *gatewayclient.Clientset, + verifyLinked bool, + protocolType gatewayv1beta1.ProtocolType, + namespace, name string, +) bool { // gather a fresh copy of the route, given the specific protocol type switch protocolType { //nolint:exhaustive - case gatewayv1alpha2.HTTPProtocolType: + case gatewayv1beta1.HTTPProtocolType: route, err := c.GatewayV1beta1().HTTPRoutes(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { t.Logf("error getting http route: %v", err) @@ -203,7 +209,7 @@ func gatewayLinkStatusMatches(t *testing.T, c *gatewayclient.Clientset, verifyLi return newRouteParentsStatus(route.Status.Parents). check(verifyLinked, string(gateway.ControllerName)) } - case gatewayv1alpha2.TCPProtocolType: + case (gatewayv1beta1.ProtocolType)(gatewayv1alpha2.TCPProtocolType): route, err := c.GatewayV1alpha2().TCPRoutes(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { t.Logf("error getting tcp route: %v", err) @@ -211,7 +217,7 @@ func gatewayLinkStatusMatches(t *testing.T, c *gatewayclient.Clientset, verifyLi return newRouteParentsStatus(route.Status.Parents). check(verifyLinked, string(gateway.ControllerName)) } - case gatewayv1alpha2.UDPProtocolType: + case (gatewayv1beta1.ProtocolType)(gatewayv1alpha2.UDPProtocolType): route, err := c.GatewayV1alpha2().UDPRoutes(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { t.Logf("error getting udp route: %v", err) @@ -219,7 +225,7 @@ func gatewayLinkStatusMatches(t *testing.T, c *gatewayclient.Clientset, verifyLi return newRouteParentsStatus(route.Status.Parents). check(verifyLinked, string(gateway.ControllerName)) } - case gatewayv1alpha2.TLSProtocolType: + case (gatewayv1beta1.ProtocolType)(gatewayv1alpha2.TLSProtocolType): route, err := c.GatewayV1alpha2().TLSRoutes(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { t.Logf("error getting tls route: %v", err) diff --git a/test/integration/httproute_test.go b/test/integration/httproute_test.go index ca407125b8..aa1f494eb0 100644 --- a/test/integration/httproute_test.go +++ b/test/integration/httproute_test.go @@ -17,7 +17,6 @@ import ( corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" @@ -54,7 +53,7 @@ func TestHTTPRouteEssentials(t *testing.T) { t.Log("deploying a new gateway") gatewayName := uuid.NewString() - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName }) require.NoError(t, err) @@ -146,7 +145,7 @@ func TestHTTPRouteEssentials(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName(service1.Name), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, }, }}, @@ -169,7 +168,7 @@ func TestHTTPRouteEssentials(t *testing.T) { cleaner.Add(httpRoute) t.Log("verifying that the Gateway gets linked to the route via status") - callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("waiting for routes from HTTPRoute to become operational") @@ -215,7 +214,7 @@ func TestHTTPRouteEssentials(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName(service1.Name), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, Weight: &httpbinWeight, }, @@ -225,7 +224,7 @@ func TestHTTPRouteEssentials(t *testing.T) { BackendObjectReference: gatewayv1beta1.BackendObjectReference{ Name: gatewayv1beta1.ObjectName(service2.Name), Port: &httpPort, - Kind: util.StringToGatewayAPIKindV1Beta1Ptr("Service"), + Kind: util.StringToGatewayAPIKindPtr("Service"), }, Weight: &nginxWeight, }, @@ -286,7 +285,7 @@ func TestHTTPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the HTTPRoute gets dropped with the parentRefs now removed") @@ -302,17 +301,17 @@ func TestHTTPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that putting the parentRefs back results in the routes becoming available again") eventuallyGETPath(t, "test-http-route-essentials", http.StatusOK, "httpbin.org", emptyHeaderSet) t.Log("deleting the GatewayClass") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the HTTPRoute gets dropped with the GatewayClass now removed") eventuallyGETPath(t, "test-http-route-essentials", http.StatusNotFound, "", emptyHeaderSet) @@ -323,41 +322,41 @@ func TestHTTPRouteEssentials(t *testing.T) { cleaner.Add(gwc) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the GatewayClass again triggers reconciliation of HTTPRoutes and the route becomes available again") eventuallyGETPath(t, "test-http-route-essentials", http.StatusOK, "httpbin.org", emptyHeaderSet) t.Log("deleting the Gateway") - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the HTTPRoute gets dropped with the Gateway now removed") eventuallyGETPath(t, "test-http-route-essentials", http.StatusNotFound, "", emptyHeaderSet) t.Log("putting the Gateway back") - gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName }) require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the Gateway again triggers reconciliation of HTTPRoutes and the route becomes available again") eventuallyGETPath(t, "test-http-route-essentials", http.StatusOK, "httpbin.org", emptyHeaderSet) t.Log("deleting both GatewayClass and Gateway rapidly") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.HTTPProtocolType, ns.Name, httpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.HTTPProtocolType, ns.Name, httpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the HTTPRoute does not get orphaned with the GatewayClass and Gateway gone") diff --git a/test/integration/httproute_webhook_test.go b/test/integration/httproute_webhook_test.go index 818e82a3fc..fe084cd531 100644 --- a/test/integration/httproute_webhook_test.go +++ b/test/integration/httproute_webhook_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" admregv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" ) @@ -50,7 +49,7 @@ func TestHTTPRouteValidationWebhook(t *testing.T) { require.NoError(t, err) t.Log("creating a managed gateway") - managedGateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(g *gatewayv1alpha2.Gateway) { + managedGateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(g *gatewayv1beta1.Gateway) { g.Name = uuid.NewString() }) require.NoError(t, err) @@ -64,7 +63,7 @@ func TestHTTPRouteValidationWebhook(t *testing.T) { cleaner.Add(unmanagedGatewayClass) t.Log("creating an unmanaged gateway") - unmanagedGateway, err := DeployGateway(ctx, gatewayClient, ns.Name, unmanagedGatewayClass.Name, func(g *gatewayv1alpha2.Gateway) { + unmanagedGateway, err := DeployGateway(ctx, gatewayClient, ns.Name, unmanagedGatewayClass.Name, func(g *gatewayv1beta1.Gateway) { g.Name = uuid.NewString() }) require.NoError(t, err) diff --git a/test/integration/tcproute_test.go b/test/integration/tcproute_test.go index 8472cb8790..6d078641ae 100644 --- a/test/integration/tcproute_test.go +++ b/test/integration/tcproute_test.go @@ -22,6 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" "github.com/kong/kubernetes-ingress-controller/v2/test" @@ -62,12 +63,12 @@ func TestTCPRouteEssentials(t *testing.T) { t.Log("deploying a gateway to the test cluster using unmanaged gateway mode and port 8888") gatewayName := uuid.NewString() - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tcp", - Protocol: gatewayv1alpha2.TCPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTCPServicePort), + Protocol: gatewayv1beta1.TCPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTCPServicePort), }} }) require.NoError(t, err) @@ -165,7 +166,7 @@ func TestTCPRouteEssentials(t *testing.T) { cleaner.Add(tcpRoute) t.Log("verifying that the Gateway gets linked to the route via status") - callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the tcpecho is responding properly") @@ -185,7 +186,7 @@ func TestTCPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the tcpecho is no longer responding") @@ -211,7 +212,7 @@ func TestTCPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that putting the parentRefs back results in the routes becoming available again") @@ -221,10 +222,10 @@ func TestTCPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the GatewayClass") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TCPRoute gets dropped with the GatewayClass now removed") @@ -238,7 +239,7 @@ func TestTCPRouteEssentials(t *testing.T) { require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the GatewayClass again triggers reconciliation of TCPRoutes and the route becomes available again") @@ -248,10 +249,10 @@ func TestTCPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the Gateway") - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TCPRoute gets dropped with the Gateway now removed") @@ -261,18 +262,18 @@ func TestTCPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("putting the Gateway back") - gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tcp", - Protocol: gatewayv1alpha2.TCPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTCPServicePort), + Protocol: gatewayv1beta1.TCPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTCPServicePort), }} }) require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the Gateway again triggers reconciliation of TCPRoutes and the route becomes available again") @@ -282,11 +283,11 @@ func TestTCPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting both GatewayClass and Gateway rapidly") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TCPRoute does not get orphaned with the GatewayClass and Gateway gone") @@ -300,18 +301,18 @@ func TestTCPRouteEssentials(t *testing.T) { require.NoError(t, err) t.Log("putting the Gateway back") - gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tcp", - Protocol: gatewayv1alpha2.TCPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTCPServicePort), + Protocol: gatewayv1beta1.TCPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTCPServicePort), }} }) require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the Gateway again triggers reconciliation of TCPRoutes and the route becomes available again") @@ -363,11 +364,11 @@ func TestTCPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting both GatewayClass and Gateway rapidly") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TCPProtocolType, ns.Name, tcpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TCPProtocolType, ns.Name, tcpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TCPRoute does not get orphaned with the GatewayClass and Gateway gone") @@ -409,12 +410,12 @@ func TestTCPRouteReferenceGrant(t *testing.T) { t.Log("deploying a gateway to the test cluster using unmanaged gateway mode") gatewayName := uuid.NewString() - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tcp", - Protocol: gatewayv1alpha2.TCPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTCPServicePort), + Protocol: gatewayv1beta1.TCPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTCPServicePort), }} }) require.NoError(t, err) diff --git a/test/integration/tlsroute_test.go b/test/integration/tlsroute_test.go index 52b84a41cd..e7b50cd6e1 100644 --- a/test/integration/tlsroute_test.go +++ b/test/integration/tlsroute_test.go @@ -23,6 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" "github.com/kong/kubernetes-ingress-controller/v2/test" @@ -135,18 +136,18 @@ func TestTLSRouteEssentials(t *testing.T) { t.Log("deploying a gateway to the test cluster using unmanaged gateway mode and port 8899") gatewayName := uuid.NewString() - hostname := gatewayv1alpha2.Hostname(tlsRouteHostname) - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + hostname := gatewayv1beta1.Hostname(tlsRouteHostname) + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tls", - Protocol: gatewayv1alpha2.TLSProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTLSServicePort), + Protocol: gatewayv1beta1.TLSProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTLSServicePort), Hostname: &hostname, - TLS: &gatewayv1alpha2.GatewayTLSConfig{ - CertificateRefs: []gatewayv1alpha2.SecretObjectReference{ + TLS: &gatewayv1beta1.GatewayTLSConfig{ + CertificateRefs: []gatewayv1beta1.SecretObjectReference{ { - Name: gatewayv1alpha2.ObjectName(tlsSecretName), + Name: gatewayv1beta1.ObjectName(tlsSecretName), }, }, }, @@ -226,7 +227,7 @@ func TestTLSRouteEssentials(t *testing.T) { cleaner.Add(tlsRoute) t.Log("verifying that the Gateway gets linked to the route via status") - callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the tcpecho is responding properly over TLS") @@ -247,7 +248,7 @@ func TestTLSRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the tcpecho is no longer responding") @@ -267,7 +268,7 @@ func TestTLSRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that putting the parentRefs back results in the routes becoming available again") @@ -278,10 +279,10 @@ func TestTLSRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the GatewayClass") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TLSRoute gets dropped with the GatewayClass now removed") @@ -296,7 +297,7 @@ func TestTLSRouteEssentials(t *testing.T) { require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the GatewayClass again triggers reconciliation of TLSRoutes and the route becomes available again") @@ -307,10 +308,10 @@ func TestTLSRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the Gateway") - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TLSRoute gets dropped with the Gateway now removed") @@ -321,17 +322,17 @@ func TestTLSRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("putting the Gateway back") - gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "tls", - Protocol: gatewayv1alpha2.TLSProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTLSServicePort), + Protocol: gatewayv1beta1.TLSProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTLSServicePort), Hostname: &hostname, - TLS: &gatewayv1alpha2.GatewayTLSConfig{ - CertificateRefs: []gatewayv1alpha2.SecretObjectReference{ + TLS: &gatewayv1beta1.GatewayTLSConfig{ + CertificateRefs: []gatewayv1beta1.SecretObjectReference{ { - Name: gatewayv1alpha2.ObjectName(tlsSecretName), + Name: gatewayv1beta1.ObjectName(tlsSecretName), }, }, }, @@ -340,7 +341,7 @@ func TestTLSRouteEssentials(t *testing.T) { require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the Gateway again triggers reconciliation of TLSRoutes and the route becomes available again") @@ -387,11 +388,11 @@ func TestTLSRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting both GatewayClass and Gateway rapidly") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gwc.Name, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gateway.Name, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.TLSProtocolType, ns.Name, tlsRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.TLSProtocolType, ns.Name, tlsRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the TLSRoute does not get orphaned with the GatewayClass and Gateway gone") @@ -458,33 +459,33 @@ func TestTLSRouteReferenceGrant(t *testing.T) { cleaner.Add(secret2) t.Log("deploying a gateway to the test cluster using unmanaged gateway mode") - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(gw *gatewayv1alpha2.Gateway) { - hostname := gatewayv1alpha2.Hostname(tlsRouteHostname) - otherHostname := gatewayv1alpha2.Hostname(tlsRouteExtraHostname) - otherNamespace := gatewayv1alpha2.Namespace(otherNs.Name) - gw.Spec.Listeners = []gatewayv1alpha2.Listener{ + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, managedGatewayClassName, func(gw *gatewayv1beta1.Gateway) { + hostname := gatewayv1beta1.Hostname(tlsRouteHostname) + otherHostname := gatewayv1beta1.Hostname(tlsRouteExtraHostname) + otherNamespace := gatewayv1beta1.Namespace(otherNs.Name) + gw.Spec.Listeners = []gatewayv1beta1.Listener{ { Name: "tls", - Protocol: gatewayv1alpha2.TLSProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTLSServicePort), + Protocol: gatewayv1beta1.TLSProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTLSServicePort), Hostname: &hostname, - TLS: &gatewayv1alpha2.GatewayTLSConfig{ - CertificateRefs: []gatewayv1alpha2.SecretObjectReference{ + TLS: &gatewayv1beta1.GatewayTLSConfig{ + CertificateRefs: []gatewayv1beta1.SecretObjectReference{ { - Name: gatewayv1alpha2.ObjectName(secrets[0].Name), + Name: gatewayv1beta1.ObjectName(secrets[0].Name), }, }, }, }, { Name: "tlsother", - Protocol: gatewayv1alpha2.TLSProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultTLSServicePort), + Protocol: gatewayv1beta1.TLSProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultTLSServicePort), Hostname: &otherHostname, - TLS: &gatewayv1alpha2.GatewayTLSConfig{ - CertificateRefs: []gatewayv1alpha2.SecretObjectReference{ + TLS: &gatewayv1beta1.GatewayTLSConfig{ + CertificateRefs: []gatewayv1beta1.SecretObjectReference{ { - Name: gatewayv1alpha2.ObjectName(secrets[1].Name), + Name: gatewayv1beta1.ObjectName(secrets[1].Name), Namespace: &otherNamespace, }, }, @@ -600,7 +601,7 @@ func TestTLSRouteReferenceGrant(t *testing.T) { }, ingressWait, waitTick) t.Log("verifying that a Listener has the invalid ref status condition") - gateway, err = gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) + gateway, err = gatewayClient.GatewayV1beta1().Gateways(ns.Name).Get(ctx, gateway.Name, metav1.GetOptions{}) require.NoError(t, err) invalid := false for _, status := range gateway.Status.Listeners { diff --git a/test/integration/udproute_test.go b/test/integration/udproute_test.go index 770699f288..c6b03e0909 100644 --- a/test/integration/udproute_test.go +++ b/test/integration/udproute_test.go @@ -20,6 +20,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" ) @@ -49,12 +50,12 @@ func TestUDPRouteEssentials(t *testing.T) { t.Log("deploying a gateway to the test cluster using unmanaged gateway mode and port 9999") gatewayName := uuid.NewString() - gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + gateway, err := DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "udp", - Protocol: gatewayv1alpha2.UDPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultUDPServicePort), + Protocol: gatewayv1beta1.UDPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultUDPServicePort), }} }) require.NoError(t, err) @@ -190,7 +191,7 @@ func TestUDPRouteEssentials(t *testing.T) { }() t.Log("verifying that the Gateway gets linked to the route via status") - callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback := GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Logf("checking DNS to resolve via UDPIngress %s", udpRoute.Name) @@ -210,7 +211,7 @@ func TestUDPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the UDPRoute gets dropped with the parentRefs now removed") @@ -232,7 +233,7 @@ func TestUDPRouteEssentials(t *testing.T) { }, time.Minute, time.Second) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that putting the parentRefs back results in the routes becoming available again") @@ -243,10 +244,10 @@ func TestUDPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the GatewayClass") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the UDPRoute gets dropped with the GatewayClass now removed") @@ -260,7 +261,7 @@ func TestUDPRouteEssentials(t *testing.T) { require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the GatewayClass again triggers reconciliation of UDPRoutes and the route becomes available again") @@ -271,10 +272,10 @@ func TestUDPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("deleting the Gateway") - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the UDPRoute gets dropped with the Gateway now removed") @@ -284,18 +285,18 @@ func TestUDPRouteEssentials(t *testing.T) { }, ingressWait, waitTick) t.Log("putting the Gateway back") - _, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1alpha2.Gateway) { + _, err = DeployGateway(ctx, gatewayClient, ns.Name, gatewayClassName, func(gw *gatewayv1beta1.Gateway) { gw.Name = gatewayName - gw.Spec.Listeners = []gatewayv1alpha2.Listener{{ + gw.Spec.Listeners = []gatewayv1beta1.Listener{{ Name: "udp", - Protocol: gatewayv1alpha2.UDPProtocolType, - Port: gatewayv1alpha2.PortNumber(ktfkong.DefaultUDPServicePort), + Protocol: gatewayv1beta1.UDPProtocolType, + Port: gatewayv1beta1.PortNumber(ktfkong.DefaultUDPServicePort), }} }) require.NoError(t, err) t.Log("verifying that the Gateway gets linked to the route via status") - callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsLinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that creating the Gateway again triggers reconciliation of UDPRoutes and the route becomes available again") @@ -335,11 +336,11 @@ func TestUDPRouteEssentials(t *testing.T) { require.Eventually(t, func() bool { return isDNSResolverReturningExpectedResult(resolver, testdomain, "10.0.0.2") }, ingressWait, waitTick) t.Log("deleting both GatewayClass and Gateway rapidly") - require.NoError(t, gatewayClient.GatewayV1alpha2().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) - require.NoError(t, gatewayClient.GatewayV1alpha2().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})) + require.NoError(t, gatewayClient.GatewayV1beta1().Gateways(ns.Name).Delete(ctx, gatewayName, metav1.DeleteOptions{})) t.Log("verifying that the Gateway gets unlinked from the route via status") - callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1alpha2.UDPProtocolType, ns.Name, udpRoute.Name) + callback = GetGatewayIsUnlinkedCallback(t, gatewayClient, gatewayv1beta1.UDPProtocolType, ns.Name, udpRoute.Name) require.Eventually(t, callback, ingressWait, waitTick) t.Log("verifying that the data-plane configuration from the UDPRoute does not get orphaned with the GatewayClass and Gateway gone")