Documentation
¶
Index ¶
- Constants
- func DeprovisionBareMetalHost(ctx context.Context, c client.Client, m *fleetv1alpha1.Machine) error
- func LabelsForCluster(clusterName, version string) map[string]string
- func LabelsForMachine(machineName, clusterName, role, version string) map[string]string
- func ReconcileBareMetalHost(ctx context.Context, c client.Client, cluster *fleetv1alpha1.Cluster, ...) error
- func ReconcileMachineConfig(ctx context.Context, c client.Client, scheme *runtime.Scheme, ...) error
- func ReconcileSecrets(ctx context.Context, c client.Client, scheme *runtime.Scheme, ...) (*secrets.Bundle, error)
- func ReconcileTalosconfig(ctx context.Context, c client.Client, scheme *runtime.Scheme, ...) error
- func TriggerBootstrap(ctx context.Context, c client.Client, bootstrapper Bootstrapper, ...) error
- type BMHNotReadyError
- type BMHState
- type Bootstrapper
- type InvalidConfigError
- type TalosBootstrapper
Constants ¶
const ( ConditionTypeReady = "Ready" ConditionSecretsReady = "SecretsReady" ConditionTalosconfigReady = "TalosconfigReady" ConditionInfrastructureReady = "InfrastructureReady" ConditionBootstrapReady = "BootstrapReady" ConditionControlPlaneReady = "ControlPlaneReady" ConditionControlPlaneInitialized = "ControlPlaneInitialized" ConditionWorkersReady = "WorkersReady" // FinalizerMachineCleanup is applied to Machine resources to ensure // BareMetalHost is deprovisioned before the Machine object is removed. FinalizerMachineCleanup = "fleet.otterscale.io/machine-cleanup" // SecretsSuffix is appended to the Cluster name for the secrets bundle Secret. SecretsSuffix = "-talos" // TalosconfigSuffix is appended to the Cluster name for the talosconfig Secret. TalosconfigSuffix = "-talosconfig" // BootstrapDataSuffix is appended to the Machine name for the bootstrap data Secret. BootstrapDataSuffix = "-bootstrap-data" // SecretsNamespace is the namespace where cluster secrets are stored. SecretsNamespace = "otterscale-system" )
const LabelRole = "fleet.otterscale.io/role"
LabelRole is the label key for the Machine role (controlplane or worker).
Variables ¶
This section is empty.
Functions ¶
func DeprovisionBareMetalHost ¶
DeprovisionBareMetalHost removes the Talos image and user data from the BareMetalHost and powers it off. This is called during Machine deletion as part of the finalizer cleanup.
func LabelsForCluster ¶
LabelsForCluster returns the standard K8s recommended labels for cluster-owned resources.
func LabelsForMachine ¶
LabelsForMachine returns the standard K8s recommended labels for machine-owned resources.
func ReconcileBareMetalHost ¶
func ReconcileBareMetalHost(ctx context.Context, c client.Client, cluster *fleetv1alpha1.Cluster, m *fleetv1alpha1.Machine) error
ReconcileBareMetalHost ensures the referenced BareMetalHost is configured with the Talos image and user data from the bootstrap Secret.
The function is idempotent: if the BMH already has the correct image and userData, no patch is issued.
func ReconcileMachineConfig ¶
func ReconcileMachineConfig(ctx context.Context, c client.Client, scheme *runtime.Scheme, cluster *fleetv1alpha1.Cluster, m *fleetv1alpha1.Machine, bundle *secrets.Bundle, version string) error
ReconcileMachineConfig ensures the bootstrap data Secret exists for the Machine. It supports two modes:
- Auto-generate (generateType=controlplane/worker): uses Talos machinery to produce config
- User-provided (generateType=none): uses the raw Data from the TalosConfigSpec
func ReconcileSecrets ¶
func ReconcileSecrets(ctx context.Context, c client.Client, scheme *runtime.Scheme, cluster *fleetv1alpha1.Cluster, version string) (*secrets.Bundle, error)
ReconcileSecrets ensures the Talos secrets bundle Secret exists for the Cluster. If the Secret does not exist, a new secrets bundle is generated using the Talos machinery library. The Secret is owned by the Cluster via OwnerReference.
func ReconcileTalosconfig ¶
func ReconcileTalosconfig(ctx context.Context, c client.Client, scheme *runtime.Scheme, cluster *fleetv1alpha1.Cluster, bundle *secrets.Bundle, endpoints []string, version string) error
ReconcileTalosconfig ensures the talosconfig client configuration Secret exists. The talosconfig allows administrators to connect to nodes via the Talos API. Endpoints are populated from Machine addresses as they become available.
func TriggerBootstrap ¶
func TriggerBootstrap(ctx context.Context, c client.Client, bootstrapper Bootstrapper, cluster *fleetv1alpha1.Cluster, m *fleetv1alpha1.Machine) error
TriggerBootstrap reads the talosconfig Secret and calls Bootstrap on the target Machine's addresses. It is a no-op if the cluster is already bootstrapped.
Types ¶
type BMHNotReadyError ¶
BMHNotReadyError indicates the BareMetalHost has not reached the expected provisioning state. The controller should requeue and check again later.
func (*BMHNotReadyError) Error ¶
func (e *BMHNotReadyError) Error() string
type BMHState ¶
type BMHState struct {
ProvisioningState string
OperationalStatus string
PoweredOn bool
ErrorMessage string
Addresses []fleetv1alpha1.MachineAddress
}
BMHState summarises the fields a controller needs from a BareMetalHost.
func GetBareMetalHostState ¶
func GetBareMetalHostState(ctx context.Context, c client.Client, m *fleetv1alpha1.Machine) (*BMHState, error)
GetBareMetalHostState reads the current state of the BareMetalHost referenced by the Machine.
func (BMHState) IsProvisioned ¶
IsProvisioned returns true when the BareMetalHost has finished writing the OS image and the host is powered on.
type Bootstrapper ¶
type Bootstrapper interface {
// Bootstrap initializes etcd on the target node. It is a no-op if etcd
// is already running.
Bootstrap(ctx context.Context, addresses []string, talosconfigData []byte) error
// IsBootstrapped checks whether any of the given addresses already have
// an etcd member directory.
IsBootstrapped(ctx context.Context, addresses []string, talosconfigData []byte) (bool, error)
}
Bootstrapper abstracts the Talos bootstrap API so it can be replaced in tests.
type InvalidConfigError ¶
InvalidConfigError is a permanent error indicating that the Talos configuration is invalid and cannot be used.
func (*InvalidConfigError) Error ¶
func (e *InvalidConfigError) Error() string
type TalosBootstrapper ¶
type TalosBootstrapper struct{}
TalosBootstrapper implements Bootstrapper using the real Talos gRPC API.
func (TalosBootstrapper) Bootstrap ¶
func (TalosBootstrapper) Bootstrap(ctx context.Context, addresses []string, talosconfigData []byte) error
Bootstrap connects to the Talos API on the given addresses and initializes etcd.
func (TalosBootstrapper) IsBootstrapped ¶
func (TalosBootstrapper) IsBootstrapped(ctx context.Context, addresses []string, talosconfigData []byte) (bool, error)
IsBootstrapped checks whether etcd data exists on any of the given nodes.