Skip to content

Commit

Permalink
Merge pull request #124 from loxilb-io/gw-run-fix
Browse files Browse the repository at this point in the history
PR: Run gateway api manager only when gateway class is mentioned in args
  • Loading branch information
UltraInstinct14 authored Mar 21, 2024
2 parents eca349b + 067399c commit 6245fe5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
38 changes: 21 additions & 17 deletions cmd/loxilb-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,6 @@ func run(o *Options) error {
}
}

gatewayClassManager := gatewayapi.NewGatewayClassManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

gatewayManager := gatewayapi.NewGatewayManager(
k8sClient, sigsClient, networkConfig, ipPool, sigsInformerFactory)

tcpRouteManager := gatewayapi.NewTCPRouteManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

udpRouteManager := gatewayapi.NewUDPRouteManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

lbManager := loadbalancer.NewLoadBalancerManager(
k8sClient,
loxilbClients,
Expand Down Expand Up @@ -222,13 +210,29 @@ func run(o *Options) error {
}()
log.StartLogFileNumberMonitor(stopCh)
informerFactory.Start(stopCh)
sigsInformerFactory.Start(stopCh)

go lbManager.Run(stopCh, loxiLBLiveCh, loxiLBPurgeCh, loxiLBSelMasterEvent)
go gatewayClassManager.Run(stopCh)
go gatewayManager.Run(stopCh)
go tcpRouteManager.Run(stopCh)
go udpRouteManager.Run(stopCh)

if networkConfig.LoxilbGatewayClass != "" {
gatewayClassManager := gatewayapi.NewGatewayClassManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

gatewayManager := gatewayapi.NewGatewayManager(
k8sClient, sigsClient, networkConfig, ipPool, sigsInformerFactory)

tcpRouteManager := gatewayapi.NewTCPRouteManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

udpRouteManager := gatewayapi.NewUDPRouteManager(
k8sClient, sigsClient, networkConfig, sigsInformerFactory)

sigsInformerFactory.Start(stopCh)

go gatewayClassManager.Run(stopCh)
go gatewayManager.Run(stopCh)
go tcpRouteManager.Run(stopCh)
go udpRouteManager.Run(stopCh)
}

<-stopCh

Expand Down
5 changes: 2 additions & 3 deletions cmd/loxilb-agent/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,11 @@ func (o *Options) setDefaults() {
if o.config.LoxilbLoadBalancerClass == "" {
o.config.LoxilbLoadBalancerClass = "loxilb.io/loxilb"
}
if o.config.LoxilbGatewayClass == "" {
o.config.LoxilbGatewayClass = "loxilb.io/loxilb"
}

if o.config.ExternalCIDR == "" {
o.config.ExternalCIDR = "123.123.123.1/24"
}

if o.config.ExternalSecondaryCIDRs == nil {
o.config.ExternalSecondaryCIDRs = []string{}
}
Expand Down

0 comments on commit 6245fe5

Please sign in to comment.