Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable CPLB load balancer #5397

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,12 @@ Configuration options related to k0s's [control plane load balancing] feature

Configuration options related to keepalived in [control plane load balancing]

| Element | Description |
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
| `vrrpInstances` | Configuration options related to the VRRP. This is an array which allows to configure multiple virtual IPs. |
| `virtualServers` | Configuration options related LoadBalancing. This is an array which allows to configure multiple LBs. |
| Element | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `vrrpInstances` | Configuration options related to the VRRP. This is an array which allows to configure multiple virtual IPs. |
| `virtualServers` | Configuration options related LoadBalancing. This is an array which allows to configure multiple LBs. |
| `userSpaceProxyBindPort` | The port the userspace proxy will bind to. This port is for internal use only, but listens on every interface. Default: `6444` |
| `disableLoadBalancer` | Disables the load balancer. Default: `false` |

##### `spec.network.controlPlaneLoadBalancing.keepalived.vrrpInstances`

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/iface/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func FirstPublicAddress() (string, error) {
}
for a := range addresses {
// check the address type and skip if loopback
if a != nil && !a.IP.IsLoopback() {
if !a.IP.IsLoopback() {
if a.IP.To4() != nil {
return a.IP.String(), nil
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/apis/k0s/v1beta1/cplb.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ type KeepalivedSpec struct {
// which allows to configure multiple load balancers.
VirtualServers VirtualServers `json:"virtualServers,omitempty"`
// UserspaceProxyPort is the port where the userspace proxy will bind
// to. This port is only exposed on the localhost interface and is only
// used internally. Defaults to 6444.
// to. This port is only used internally, but listens on every interface.
// Defaults to 6444
// +kubebuilder:default=6444
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
// +optional
UserSpaceProxyPort int `json:"userSpaceProxyBindPort,omitempty"`
// DisableLoadBalancer disables the load balancer.
// +optional
DisableLoadBalancer bool `json:"disableLoadBalancer,omitempty"`
}

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

if len(k.Config.VRRPInstances) > 0 || len(k.Config.VirtualServers) > 0 {
if !k.Config.DisableLoadBalancer && (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)
Expand Down Expand Up @@ -160,6 +160,7 @@ func (k *Keepalived) Start(ctx context.Context) error {
}
}()
}

return k.supervisor.Supervise()
}

Expand Down
7 changes: 5 additions & 2 deletions static/_crds/k0s/k0s.k0sproject.io_clusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,15 @@ spec:
Keepalived contains configuration options related to the "Keepalived" type
of load balancing.
properties:
disableLoadBalancer:
description: DisableLoadBalancer disables the load balancer.
type: boolean
userSpaceProxyBindPort:
default: 6444
description: |-
UserspaceProxyPort is the port where the userspace proxy will bind
to. This port is only exposed on the localhost interface and is only
used internally. Defaults to 6444.
to. This port is only used internally, but listens on every interface.
Defaults to 6444
maximum: 65535
minimum: 1
type: integer
Expand Down
Loading