-
-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
User Story
As a KSail user,
I want a --load-balancer flag for ksail cluster init and ksail cluster create commands,
So that I can control LoadBalancer service support based on my distribution × provider combination (e.g., Cloud Provider KIND for Vanilla × Docker, hcloud-cloud-controller-manager for Talos × Hetzner).
Acceptance Criteria
Enum and Configuration
- Add
LoadBalancerenum topkg/apis/cluster/v1alpha1/enums.gowith values:Default- Rely on distribution × provider defaults (e.g., Talos × Hetzner gets hcloud-cloud-controller-manager automatically)Enabled- Enable the most native LoadBalancer controller for the combinationDisabled- Disable any default LoadBalancer controller
- Add
LoadBalancer LoadBalancerfield toClusterSpecinpkg/apis/cluster/v1alpha1/types.go - Add distribution method
ProvidesLoadBalancerByDefault(provider Provider) boolto determine if a combination includes native LoadBalancer support
CLI Integration
- Add
DefaultLoadBalancerFieldSelector()topkg/io/config-manager/ksail/field_selector.go - Add field selector to
InitFieldSelectors()inpkg/cli/cmd/cluster/init.go - Add field selector to
CreateFieldSelectors()inpkg/cli/cmd/cluster/create.go - Flag should support loading order: flags → env (
KSAIL_LOAD_BALANCER) → config → default
Scaffolding Integration
- K3d: Add
--disable=servicelbtoextraArgswhenLoadBalancer == Disabledinscaffolder.go(K3s includes ServiceLB by default) - Kind: No default LoadBalancer; document that
Enabledinstalls Cloud Provider KIND - Talos × Docker: No default LoadBalancer;
Enabledinstalls MetalLB (L2 mode) - Talos × Hetzner: Document that
DefaultorEnabledinstalls hcloud-cloud-controller-manager
Component Installation
- Add
NeedsLoadBalancertoComponentRequirementsinpkg/cli/setup/post_cni.go - Add
InstallLoadBalancerSilent()function following the pattern ofInstallMetricsServerSilent() - Create
pkg/svc/installer/cloud-provider-kind/installer for Vanilla × Docker - Create
pkg/svc/installer/metallb/installer for Talos × Docker - Create
pkg/svc/installer/hcloud-ccm/installer for Talos × Hetzner (hcloud-cloud-controller-manager) - Wire up factory in
DefaultInstallerFactories()inpkg/cli/setup/components.go
Documentation
- Update CLI documentation in
docs/configuration/cli-flags/cluster/ - Document distribution × provider LoadBalancer support matrix
Testing
- Unit tests for
LoadBalancerenum (Set, String, Type, Default, ValidValues) - Unit tests for
ProvidesLoadBalancerByDefault()method - Unit tests for field selector binding
- Integration tests for scaffolding output with different LoadBalancer settings
Distribution × Provider Support Matrix
| Distribution | Provider | Default Behavior | Enabled Behavior |
|---|---|---|---|
| Vanilla | Docker | No LoadBalancer | Cloud Provider KIND |
| K3s | Docker | ServiceLB (Klipper) | ServiceLB (Klipper) |
| Talos | Docker | No LoadBalancer | MetalLB (L2 mode) |
| Talos | Hetzner | hcloud-cloud-controller-manager | hcloud-cloud-controller-manager |
Note: Klipper-LB (ServiceLB) could technically work on Talos × Docker since it's just a DaemonSet, but MetalLB is the more common choice for non-K3s distributions due to better documentation and wider support.
Implementation Notes
Relevant Code Patterns
- Follow the
MetricsServerenum pattern withDefault/Enabled/Disabledvalues - Use the existing installer factory pattern from
pkg/cli/setup/components.go - Reference the
ProvidesMetricsServerByDefault()method for the distribution method pattern
Key Files to Modify
pkg/apis/cluster/v1alpha1/enums.go- Add LoadBalancer enumpkg/apis/cluster/v1alpha1/types.go- Add LoadBalancer to ClusterSpecpkg/io/config-manager/ksail/field_selector.go- Add field selectorpkg/cli/cmd/cluster/init.go- Add to InitFieldSelectors()pkg/cli/cmd/cluster/create.go- Add to CreateFieldSelectors()pkg/io/scaffolder/scaffolder.go- Handle in CreateK3dConfig(), buildKindConfig()pkg/cli/setup/components.go- Add installer factorypkg/cli/setup/post_cni.go- Add to ComponentRequirements and installation logicpkg/svc/installer/- New installer packages
External Dependencies
- Cloud Provider KIND - For Vanilla × Docker
- MetalLB - For Talos × Docker
- hcloud-cloud-controller-manager - For Talos × Hetzner
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Done