diff --git a/cmd/main.go b/cmd/main.go index 4708df6..d9a474a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -51,7 +51,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(corev1.AddToScheme(scheme)) utilruntime.Must(istioclient.AddToScheme(scheme)) - utilruntime.Must(gateway.AddToScheme(scheme)) + utilruntime.Must(gateway.Install(scheme)) // +kubebuilder:scaffold:scheme } diff --git a/internal/controller/core/flow_controller.go b/internal/controller/core/flow_controller.go index 4e4734e..9b81eae 100644 --- a/internal/controller/core/flow_controller.go +++ b/internal/controller/core/flow_controller.go @@ -18,15 +18,14 @@ package core import ( "context" - "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/runtime" + corev1 "kardinal.dev/kardinal-operator/api/core/v1" + "kardinal.dev/kardinal-operator/kardinal/reconciler" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - - corev1 "kardinal.dev/kardinal-operator/api/core/v1" - "kardinal.dev/kardinal-operator/kardinal/reconciler" ) // FlowReconciler reconciles a Flow object diff --git a/kardinal/resources/resources.go b/kardinal/resources/resources.go index 57efabe..54ba2e7 100644 --- a/kardinal/resources/resources.go +++ b/kardinal/resources/resources.go @@ -2,7 +2,6 @@ package resources import ( "context" - gateway "sigs.k8s.io/gateway-api/apis/v1" "strings" "github.com/kurtosis-tech/stacktrace" @@ -15,6 +14,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kardinalcorev1 "kardinal.dev/kardinal-operator/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" + gateway "sigs.k8s.io/gateway-api/apis/v1" ) const ( @@ -201,7 +201,7 @@ func ApplyResources( } } else { namespaceObjectLabels := namespaceObject.GetLabels() - //OPERATOR-TODO we have to check if it was marked for deletion by Kubernetes and handle it that situation + // OPERATOR-TODO we have to check if it was marked for deletion by Kubernetes and handle it that situation isManaged, found := namespaceObjectLabels[kardinalManagedLabelKey] if found && isManaged == trueStr { if !compareObjectsFunc(clusterTopologyNamespaceObject, namespaceObject) { diff --git a/kardinal/topology/topology.go b/kardinal/topology/topology.go index 79abec1..861f229 100644 --- a/kardinal/topology/topology.go +++ b/kardinal/topology/topology.go @@ -3,9 +3,7 @@ package topology import ( "context" "fmt" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "reflect" - gateway "sigs.k8s.io/gateway-api/apis/v1" "strings" "github.com/brunoga/deep" @@ -17,8 +15,10 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" net "k8s.io/api/networking/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "kardinal.dev/kardinal-operator/kardinal/resources" "sigs.k8s.io/controller-runtime/pkg/client" + gateway "sigs.k8s.io/gateway-api/apis/v1" ) const ( @@ -211,7 +211,7 @@ func (clusterTopology *ClusterTopology) GetResources() (*resources.Resources, er frontServices := []*corev1.Service{} // OPERATOR-TODO include []istioclient.EnvoyFilter as the third returned value once we add the envoy filters objects - //routes, frontServices, inboundFrontFilters := clusterTopology.getHttpRoutes() + // routes, frontServices, inboundFrontFilters := clusterTopology.getHttpRoutes() routes, frontServicesFromHttpRoutes := clusterTopology.getHttpRoutes() groupedRoutes := lo.GroupBy(routes, func(routes *gateway.HTTPRoute) string { return routes.Namespace }) for namespace, routes := range groupedRoutes { @@ -562,7 +562,7 @@ func (clusterTopology *ClusterTopology) getHttpRoutes() ([]*gateway.HTTPRoute, [ frontServices := map[string]*corev1.Service{} // OPERATOR-TODO include []istioclient.EnvoyFilter as the third returned value once we add the envoy filters objects - //filters := []istioclient.EnvoyFilter{} + // filters := []istioclient.EnvoyFilter{} for _, activeFlowID := range clusterTopology.GatewayAndRoutes.ActiveFlowIDs { logrus.Infof("Setting gateway route for active flow ID: %v", activeFlowID) @@ -589,20 +589,20 @@ func (clusterTopology *ClusterTopology) getHttpRoutes() ([]*gateway.HTTPRoute, [ if !serviceAlreadyAdded { frontServices[idVersion] = target.GetVersionedService(activeFlowID, namespace) ref.Name = gateway.ObjectName(idVersion) - //OPERATOR-TODO creo que tambien el problema es que hay 2 http route para el baseline flow + // OPERATOR-TODO creo que tambien el problema es que hay 2 http route para el baseline flow rule.BackendRefs[refIx] = ref // OPERATOR-TODO include []istioclient.EnvoyFilter as the third returned value once we add the envoy filters objects //hostnames := lo.Map(routeSpec.Hostnames, func(item gateway.Hostname, _ int) string { return string(item) }) // Set Envoy FIlter for the service - //filter := &externalInboudFilter{ + // filter := &externalInboudFilter{ // filter: generateDynamicLuaScript(allServices, activeFlowID, namespace, hostnames), // name: strings.Join(hostnames, "-"), - //} - //inboundFilter := getInboundFilter(target.ServiceID, namespace, -1, &target.Version, filter) - //logrus.Debugf("Adding inbound filter to setup routing table for flow '%s' on service '%s', version '%s'", activeFlowID, target.ServiceID, target.Version) - //filters = append(filters, inboundFilter) + // } + // inboundFilter := getInboundFilter(target.ServiceID, namespace, -1, &target.Version, filter) + // logrus.Debugf("Adding inbound filter to setup routing table for flow '%s' on service '%s', version '%s'", activeFlowID, target.ServiceID, target.Version) + // filters = append(filters, inboundFilter) } } else { logrus.Errorf(">> service not found %v", ref.Name)