Skip to content

Commit

Permalink
Merge branch 'main' into refactor/addLbFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder authored Dec 26, 2024
2 parents 8409f60 + 240b417 commit b03c844
Show file tree
Hide file tree
Showing 66 changed files with 2,422 additions and 167 deletions.
35 changes: 27 additions & 8 deletions cmd/loxilb-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ import (
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/bgppolicyapply"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/bgppolicydefinedsets"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/bgppolicydefinition"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/egress"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/gatewayapi"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/loadbalancer"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/loxiurl"
"github.com/loxilb-io/kube-loxilb/pkg/api"
bgpCRDinformers "github.com/loxilb-io/kube-loxilb/pkg/bgp-client/informers/externalversions"
egressCRDinformers "github.com/loxilb-io/kube-loxilb/pkg/egress-client/informers/externalversions"
"github.com/loxilb-io/kube-loxilb/pkg/ippool"
"github.com/loxilb-io/kube-loxilb/pkg/k8s"
klbCRDinformers "github.com/loxilb-io/kube-loxilb/pkg/klb-client/informers/externalversions"

"github.com/loxilb-io/kube-loxilb/pkg/log"

"k8s.io/client-go/informers"
Expand Down Expand Up @@ -64,7 +67,8 @@ func run(o *Options) error {
klog.Infof(" Build: %s", BuildInfo)

// create k8s Clientset, CRD Clientset and SharedInformerFactory for the given config.
k8sClient, _, bgpCRDClient, klbCRDClient, k8sExtClient, sigsClient, err := k8s.CreateClients(o.config.ClientConnection, "")
// TODO: crdClient must be integrated into one.
k8sClient, _, bgpCRDClient, klbCRDClient, egressClient, k8sExtClient, sigsClient, err := k8s.CreateClients(o.config.ClientConnection, "")
if err != nil {
return fmt.Errorf("error creating k8s clients: %v", err)
}
Expand All @@ -78,6 +82,9 @@ func run(o *Options) error {

loxilbURLInformerFactory := klbCRDinformers.NewSharedInformerFactory(klbCRDClient, informerDefaultResync)
loxilbURLInformer := loxilbURLInformerFactory.Loxiurl().V1().LoxiURLs()

egressInformerFactory := egressCRDinformers.NewSharedInformerFactory(egressClient, informerDefaultResync)
egressInformer := egressInformerFactory.Egress().V1().Egresses()
sigsInformerFactory := sigsInformer.NewSharedInformerFactory(sigsClient, informerDefaultResync)

// networkReadyCh is used to notify that the Node's network is ready.
Expand Down Expand Up @@ -174,8 +181,10 @@ func run(o *Options) error {
}
}

loxilbClients := make([]*api.LoxiClient, 0)
loxilbPeerClients := make([]*api.LoxiClient, 0)
//loxilbClients := make([]*api.LoxiClient, 0)
//loxilbPeerClients := make([]*api.LoxiClient, 0)
loxilbClients := api.NewLoxiClientPool()
loxilbPeerClients := api.NewLoxiClientPool()
loxiLBLiveCh := make(chan *api.LoxiClient, 50)
loxiLBPurgeCh := make(chan *api.LoxiClient, 5)
loxiLBSelMasterEvent := make(chan bool)
Expand All @@ -188,7 +197,7 @@ func run(o *Options) error {
if err != nil {
return err
}
loxilbClients = append(loxilbClients, loxilbClient)
loxilbClients.AddLoxiClient(loxilbClient)
}
}

Expand All @@ -207,30 +216,30 @@ func run(o *Options) error {
bgpCRDClient,
networkConfig,
BGPPeerInformer,
lbManager,
loxilbClients,
)

BGPPolicyDefinedSetsManager := bgppolicydefinedsets.NewBGPPolicyDefinedSetsManager(
k8sClient,
bgpCRDClient,
networkConfig,
BGPPolicyDefinedSetInformer,
lbManager,
loxilbClients,
)

BGPPolicyDefinitionManager := bgppolicydefinition.NewBGPPolicyDefinitionManager(
k8sClient,
bgpCRDClient,
networkConfig,
BGPPolicyDefinitionInformer,
lbManager,
loxilbClients,
)
BGPPolicyApplyManager := bgppolicyapply.NewBGPPolicyApplyManager(
k8sClient,
bgpCRDClient,
networkConfig,
BGPPolicyApplyInformer,
lbManager,
loxilbClients,
)

loxilbURLMgr := loxiurl.NewLoxiLBURLManager(
Expand All @@ -242,6 +251,14 @@ func run(o *Options) error {
lbManager,
)

egressMgr := egress.NewEgressManager(
k8sClient,
egressClient,
networkConfig,
egressInformer,
loxilbClients,
)

go func() {
for {
select {
Expand Down Expand Up @@ -277,6 +294,8 @@ func run(o *Options) error {
}

go loxilbURLMgr.Start(loxilbURLInformerFactory, stopCh, loxiLBLiveCh, loxiLBDeadCh, loxiLBPurgeCh)
egressInformerFactory.Start(stopCh)
go egressMgr.Run(stopCh)

// Run gateway API managers
if o.config.EnableGatewayAPI {
Expand Down
31 changes: 12 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.31.1
k8s.io/api v0.32.0
k8s.io/apiextensions-apiserver v0.28.3
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/code-generator v0.28.3
k8s.io/apimachinery v0.32.0
k8s.io/client-go v0.32.0
k8s.io/component-base v0.28.3
k8s.io/klog/v2 v2.130.1
k8s.io/kube-aggregator v0.26.0
sigs.k8s.io/gateway-api v1.0.0
sigs.k8s.io/structured-merge-diff/v4 v4.4.1
sigs.k8s.io/structured-merge-diff/v4 v4.4.2
)

require (
Expand All @@ -27,16 +26,15 @@ require (
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -52,23 +50,18 @@ require (
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit b03c844

Please sign in to comment.