Skip to content

Commit

Permalink
Optimize egress gateway controller reconcile logic (#1243)
Browse files Browse the repository at this point in the history
Signed-off-by: lou-lan <[email protected]>
  • Loading branch information
lou-lan authored Mar 6, 2024
1 parent ac3e9a0 commit b9918cc
Show file tree
Hide file tree
Showing 6 changed files with 1,087 additions and 1,221 deletions.
22 changes: 8 additions & 14 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ package controller
import (
"context"
"fmt"
"github.com/spidernet-io/egressgateway/pkg/controller/endpoint"
"github.com/spidernet-io/egressgateway/pkg/controller/policy"
"github.com/spidernet-io/egressgateway/pkg/controller/tunnel"

"github.com/go-logr/logr"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -19,7 +16,9 @@ import (

"github.com/spidernet-io/egressgateway/pkg/config"
egressclusterinfo "github.com/spidernet-io/egressgateway/pkg/controller/egress_cluster_info"
"github.com/spidernet-io/egressgateway/pkg/controller/endpoint"
"github.com/spidernet-io/egressgateway/pkg/controller/metrics"
"github.com/spidernet-io/egressgateway/pkg/controller/tunnel"
"github.com/spidernet-io/egressgateway/pkg/controller/webhook"
"github.com/spidernet-io/egressgateway/pkg/egressgateway"
"github.com/spidernet-io/egressgateway/pkg/logger"
Expand Down Expand Up @@ -61,27 +60,22 @@ func New(cfg *config.Config) (types.Service, error) {
return nil, fmt.Errorf("failed to create manager: %w", err)
}

cli, err := client.New(cfg.KubeConfig, client.Options{Scheme: schema.GetScheme()})
if err != nil {
return nil, err
}

if err = setManger(mgr, cfg, log); err != nil {
return nil, err
}

metrics.RegisterMetricCollectors()

err = egressgateway.NewEgressGatewayController(mgr, log, cfg)
err = egressgateway.NewEgressGatewayController(mgr, log, cfg, cli)
if err != nil {
return nil, fmt.Errorf("failed to create egress gateway controller: %w", err)
}

err = policy.NewEgressPolicyController(mgr, log, cfg)
if err != nil {
return nil, fmt.Errorf("failed to create egress policy controller: %w", err)
}

err = policy.NewEgressClusterPolicyController(mgr, log, cfg)
if err != nil {
return nil, fmt.Errorf("failed to create egress cluster policy controller: %w", err)
}

err = tunnel.NewEgressTunnelController(mgr, log, cfg)
if err != nil {
return nil, fmt.Errorf("failed to create egress tunnel controller: %w", err)
Expand Down
125 changes: 0 additions & 125 deletions pkg/controller/policy/egress_cluster_policy.go

This file was deleted.

129 changes: 0 additions & 129 deletions pkg/controller/policy/egress_policy.go

This file was deleted.

Loading

0 comments on commit b9918cc

Please sign in to comment.