Documentation
¶
Overview ¶
Package bootstrap provides services for bootstrapping Flux in Butler.
Copyright (c) 2025, The Butler Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package bootstrap provides functionality for initializing and configuring Kube-OVN in Butler.
Copyright (c) 2025, The Butler Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func FindVipHolder(ctx context.Context, talos *talos.TalosAdapter, vip string, nodes []string, ...) (string, error)
- type BootstrapService
- type FluxInitializer
- type HealthChecker
- type KubeConfigManager
- type KubeOvnInitializer
- func (k *KubeOvnInitializer) ConfigureKubeOvn(ctx context.Context, controlPlaneIPs []string, config *models.BootstrapConfig) error
- func (k *KubeOvnInitializer) LabelNodes(ctx context.Context, config *models.BootstrapConfig, ...) error
- func (k *KubeOvnInitializer) WaitForNodes(ctx context.Context, server string, timeout time.Duration) error
- type KubeVipInitializer
- func (k *KubeVipInitializer) ApplyDaemonSet(ctx context.Context, server string) error
- func (k *KubeVipInitializer) ApplyRBAC(ctx context.Context, server string) error
- func (k *KubeVipInitializer) ConfigureKubeVip(ctx context.Context, config *models.BootstrapConfig, server string) error
- func (k *KubeVipInitializer) GenerateManifest(ctx context.Context, config *models.BootstrapConfig) error
- type Provisioner
- type TalosInitializer
- func (t *TalosInitializer) ApplyConfig(ctx context.Context, node, configDir, configFile string, insecure bool) error
- func (t *TalosInitializer) BootstrapControlPlane(ctx context.Context, node string) error
- func (t *TalosInitializer) ConfigureTalos(ctx context.Context, config *models.TalosConfig, insecure bool) error
- func (t *TalosInitializer) GenerateConfig(ctx context.Context, config *models.TalosConfig) error
- func (t *TalosInitializer) RetrieveKubeConfig(ctx context.Context, node string) error
- func (t *TalosInitializer) SetEndpoint(ctx context.Context, node string) error
- func (t *TalosInitializer) WaitForNodesToRegister()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindVipHolder ¶
func FindVipHolder(ctx context.Context, talos *talos.TalosAdapter, vip string, nodes []string, logger *zap.Logger) (string, error)
FindVipHolder checks which control plane node is holding the VIP. This uses the /proc/net/fib_trie file to determine the node holding the VIP. Most reliable way to check for VIP holder using the network stack directly.
Types ¶
type BootstrapService ¶
type BootstrapService struct {
// contains filtered or unexported fields
}
BootstrapService orchestrates provisioning the management cluster.
func NewBootstrapService ¶
func NewBootstrapService(ctx context.Context, config *models.BootstrapConfig, logger *zap.Logger) (*BootstrapService, error)
NewBootstrapService initializes BootstrapService using Viper for config.
func (*BootstrapService) ProvisionManagementCluster ¶
func (b *BootstrapService) ProvisionManagementCluster() error
ProvisionManagementCluster provisions the management cluster.
type FluxInitializer ¶
type FluxInitializer struct {
// contains filtered or unexported fields
}
FluxInitializer handles bootstrapping FluxCD into the management cluster.
func NewFluxInitializer ¶
func NewFluxInitializer(fluxAdapter *flux.FluxAdapter, logger *zap.Logger) *FluxInitializer
NewFluxInitializer creates a new Flux initializer.
func (*FluxInitializer) FluxBootstrap ¶
func (f *FluxInitializer) FluxBootstrap(ctx context.Context, config *models.BootstrapConfig) error
FluxBootstrap initializes FluxCD on the management cluster with retries.
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker waits for VMs to report healthy and have allocated IPs.
func NewHealthChecker ¶
func NewHealthChecker(provider providers.ProviderInterface, logger *zap.Logger) *HealthChecker
NewHealthChecker initializes a HealthChecker.
func (*HealthChecker) WaitForVMsToBeReady ¶
func (h *HealthChecker) WaitForVMsToBeReady(config *models.BootstrapConfig, timeout time.Duration) (map[string]string, error)
WaitForVMsToBeReady waits for all VMs to become healthy and collects their assigned IPs.
type KubeConfigManager ¶
type KubeConfigManager struct {
// contains filtered or unexported fields
}
KubeConfigManager handles kubeconfig validation and Kubernetes API readiness checks.
func NewKubeConfigManager ¶
func NewKubeConfigManager(logger *zap.Logger, platformAdapter platforms.PlatformAdapter) *KubeConfigManager
NewKubeConfigManager initializes a KubeConfigManager.
func (*KubeConfigManager) EnsureCorrectContext ¶
func (k *KubeConfigManager) EnsureCorrectContext(kubeconfigPath string, clusterName string) error
EnsureCorrectContext ensures the kubeconfig context is set correctly.
func (*KubeConfigManager) ValidateKubeConfig ¶
func (k *KubeConfigManager) ValidateKubeConfig(kubeconfigPath string) error
ValidateKubeConfig ensures the kubeconfig is valid.
func (*KubeConfigManager) WaitForKubernetesAPI ¶
func (k *KubeConfigManager) WaitForKubernetesAPI(kubeconfigPath, controlPlaneNode string, timeout time.Duration) error
WaitForKubernetesAPI ensures that the Kubernetes API is accessible.
type KubeOvnInitializer ¶
type KubeOvnInitializer struct {
// contains filtered or unexported fields
}
KubeOvnInitializer provides functionality to bootstrap Kube-OVN, including Helm install and node labeling for control and worker planes.
func NewKubeOvnInitializer ¶
func NewKubeOvnInitializer(kubectl *kubectl.KubectlAdapter, helm *helm.HelmAdapter, talos *talos.TalosAdapter, logger *zap.Logger) *KubeOvnInitializer
NewKubeOvnInitializer constructs a new KubeOvnInitializer instance.
func (*KubeOvnInitializer) ConfigureKubeOvn ¶
func (k *KubeOvnInitializer) ConfigureKubeOvn(ctx context.Context, controlPlaneIPs []string, config *models.BootstrapConfig) error
ConfigureKubeOvn generates a rendered values.yaml file and performs a Helm install of the Kube-OVN chart using the VIP and remaining control plane IPs. The bound control plane node IP is excluded from the list.
func (*KubeOvnInitializer) LabelNodes ¶
func (k *KubeOvnInitializer) LabelNodes( ctx context.Context, config *models.BootstrapConfig, controlPlaneIPs, workerIPs []string, ipToNodeNameMap map[string]string, ) error
LabelNodes applies Kube-OVN-specific labels to control plane and worker nodes. Control plane nodes receive 'kube-ovn/role=master'; workers get 'node-role.kubernetes.io/worker='.
func (*KubeOvnInitializer) WaitForNodes ¶
func (k *KubeOvnInitializer) WaitForNodes(ctx context.Context, server string, timeout time.Duration) error
WaitForNodes waits until at least one node is registered and in Ready state, polling every 5 seconds up to the provided timeout.
type KubeVipInitializer ¶
type KubeVipInitializer struct {
// contains filtered or unexported fields
}
KubeVipInitializer handles generating and deploying the Kube-Vip manifest.
func NewKubeVipInitializer ¶
func NewKubeVipInitializer(docker *docker.DockerAdapter, kubectl *kubectl.KubectlAdapter, logger *zap.Logger) *KubeVipInitializer
NewKubeVipInitializer creates a new KubeVip initializer.
func (*KubeVipInitializer) ApplyDaemonSet ¶
func (k *KubeVipInitializer) ApplyDaemonSet(ctx context.Context, server string) error
ApplyDaemonSet applies the Kube-Vip DaemonSet.
func (*KubeVipInitializer) ApplyRBAC ¶
func (k *KubeVipInitializer) ApplyRBAC(ctx context.Context, server string) error
ApplyRBAC applies the Kube-Vip RBAC manifest.
func (*KubeVipInitializer) ConfigureKubeVip ¶
func (k *KubeVipInitializer) ConfigureKubeVip(ctx context.Context, config *models.BootstrapConfig, server string) error
ConfigureKubeVip performs all steps to set up Kube-Vip: generating the manifest, applying RBAC, and deploying the DaemonSet.
func (*KubeVipInitializer) GenerateManifest ¶
func (k *KubeVipInitializer) GenerateManifest(ctx context.Context, config *models.BootstrapConfig) error
GenerateManifest creates the Kube-Vip DaemonSet manifest.
type Provisioner ¶
type Provisioner struct {
// contains filtered or unexported fields
}
Provisioner handles VM provisioning.
func NewProvisioner ¶
func NewProvisioner(provider providers.ProviderInterface, logger *zap.Logger) *Provisioner
NewProvisioner initializes a Provisioner.
func (*Provisioner) ProvisionVMs ¶
func (p *Provisioner) ProvisionVMs(config *models.BootstrapConfig) error
ProvisionVMs provisions the required VMs for the management cluster.
func (*Provisioner) SeparateNodesByRole ¶
func (p *Provisioner) SeparateNodesByRole(config *models.BootstrapConfig, nodeIPs map[string]string) ([]string, []string, error)
SeparateNodesByRole classifies VMs into control planes and workers based on role.
type TalosInitializer ¶
type TalosInitializer struct {
// contains filtered or unexported fields
}
TalosInitializer handles configuring Talos on provisioned VMs.
func NewTalosInitializer ¶
func NewTalosInitializer(talosAdapter *talos.TalosAdapter, logger *zap.Logger) *TalosInitializer
NewTalosInitializer creates a new Talos initializer.
func (*TalosInitializer) ApplyConfig ¶
func (t *TalosInitializer) ApplyConfig(ctx context.Context, node, configDir, configFile string, insecure bool) error
ApplyConfig applies the Talos configuration to a node.
func (*TalosInitializer) BootstrapControlPlane ¶
func (t *TalosInitializer) BootstrapControlPlane(ctx context.Context, node string) error
BootstrapControlPlane bootstraps Talos on a control-plane node.
func (*TalosInitializer) ConfigureTalos ¶
func (t *TalosInitializer) ConfigureTalos(ctx context.Context, config *models.TalosConfig, insecure bool) error
ConfigureTalos sets up Talos on the cluster nodes.
func (*TalosInitializer) GenerateConfig ¶
func (t *TalosInitializer) GenerateConfig(ctx context.Context, config *models.TalosConfig) error
GenerateConfig generates Talos configuration files.
func (*TalosInitializer) RetrieveKubeConfig ¶
func (t *TalosInitializer) RetrieveKubeConfig(ctx context.Context, node string) error
RetrieveKubeConfig fetches and stores the Kubernetes kubeconfig.
func (*TalosInitializer) SetEndpoint ¶
func (t *TalosInitializer) SetEndpoint(ctx context.Context, node string) error
SetEndpoint configures the Talos endpoint.
func (*TalosInitializer) WaitForNodesToRegister ¶
func (t *TalosInitializer) WaitForNodesToRegister()
WaitForNodesToRegister adds a delay to allow nodes to register.