Skip to content

Commit

Permalink
Allow to disable CPLB load balancer
Browse files Browse the repository at this point in the history
This is one of the remaining tasks of k0sproject#5279. The intended use case for
this is to allow to use the VIPs functionality while using some user
provided load balancer such as HAProxy, nginx, etc...

Signed-off-by: Juan-Luis de Sousa-Valadas Castaño <[email protected]>
  • Loading branch information
juanluisvaladas committed Jan 2, 2025
1 parent d43f482 commit 1b696b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/k0s/v1beta1/cplb.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ type KeepalivedSpec struct {
// +kubebuilder:validation:Maximum=65535
// +optional
UserSpaceProxyPort int `json:"userSpaceProxyBindPort,omitempty"`
// DisableLoadBalanmcer disables the load balancer.
// +optional
DisableLoadBalancer bool `json:"disableLoadBalancer,omitempty"`
}

// VRRPInstances is a list of VRRPInstance
Expand Down
17 changes: 10 additions & 7 deletions pkg/component/controller/cplb/cplb_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ func (k *Keepalived) Start(ctx context.Context) error {
}
}

if len(k.Config.VRRPInstances) > 0 || len(k.Config.VirtualServers) > 0 {
k.log.Info("Starting CPLB reconciler")
updateCh := make(chan struct{}, 1)
k.reconciler = NewCPLBReconciler(k.KubeConfigPath, updateCh)
k.updateCh = updateCh
if err := k.reconciler.Start(); err != nil {
return fmt.Errorf("failed to start CPLB reconciler: %w", err)
if !k.Config.DisableLoadBalancer {
if len(k.Config.VRRPInstances) > 0 || len(k.Config.VirtualServers) > 0 {
k.log.Info("Starting CPLB reconciler")
updateCh := make(chan struct{}, 1)
k.reconciler = NewCPLBReconciler(k.KubeConfigPath, updateCh)
k.updateCh = updateCh
if err := k.reconciler.Start(); err != nil {
return fmt.Errorf("failed to start CPLB reconciler: %w", err)
}
}
}

Expand Down Expand Up @@ -160,6 +162,7 @@ func (k *Keepalived) Start(ctx context.Context) error {
}
}()
}

return k.supervisor.Supervise()
}

Expand Down
3 changes: 3 additions & 0 deletions static/_crds/k0s/k0s.k0sproject.io_clusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ spec:
Keepalived contains configuration options related to the "Keepalived" type
of load balancing.
properties:
disableLoadBalancer:
description: DisableLoadBalanmcer disables the load balancer.
type: boolean
userSpaceProxyBindPort:
default: 6444
description: |-
Expand Down

0 comments on commit 1b696b1

Please sign in to comment.