Documentation
¶
Index ¶
Constants ¶
const ( // RequeueAfterReady is the requeue interval for machines in Ready phase. RequeueAfterReady = 5 * time.Minute // RequeueAfterPending is the requeue interval for machines in Pending phase. RequeueAfterPending = 30 * time.Second // RequeueAfterFailed is the requeue interval for machines in Failed phase. RequeueAfterFailed = 1 * time.Minute // RequeueAfterJoining is the requeue interval for machines in // Joining phase. Short interval because we are waiting for the // Node to appear with the matching label. RequeueAfterJoining = 30 * time.Second // TODO: Make this configurable ProvisioningTimeout = 5 * time.Minute // TCPProbeTimeout is the timeout for TCP connection probes. TCPProbeTimeout = 10 * time.Second // SSHConnectTimeout is the timeout for SSH connections. SSHConnectTimeout = 30 * time.Second // SecretNamespaceUnboundedKube is the namespace where SSH key secrets // must reside. Machine is cluster-scoped, so we use a fixed namespace // for secret lookup. SecretNamespaceUnboundedKube = "unbounded-kube" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusterInfo ¶
type ClusterInfo struct {
// APIServer is the HTTPS endpoint of the Kubernetes API server
// (e.g. "my-cluster-dns-abc123.hcp.eastus.azmk8s.io:443").
APIServer string
// CACertBase64 is the base64-encoded cluster CA certificate from the
// kube-root-ca.crt ConfigMap in the kube-public namespace.
CACertBase64 string
// ClusterDNS is the ClusterIP of the kube-dns Service in kube-system.
ClusterDNS string
// Provider is the detected cluster provider (e.g. AKS). It is nil
// when the provider cannot be determined.
Provider cloudprovider.Provider
// KubeVersion is the Kubernetes server version (e.g. "v1.34.2") obtained
// from the API server's /version endpoint. It is used as the default
// KUBE_VERSION for bootstrap scripts unless the Machine's
// Spec.Kubernetes.Version overrides it.
KubeVersion string
}
ClusterInfo holds cluster-level values resolved once at startup and passed to bootstrap scripts as environment variables.
func ResolveClusterInfo ¶
func ResolveClusterInfo(ctx context.Context, cfg Config, k kubernetes.Interface) (*ClusterInfo, error)
ResolveClusterInfo queries the Kubernetes API to populate all four dynamic values needed by the bootstrap script. It is intended to be called once at controller startup so the results can be reused across reconcile loops.
type Config ¶
type Config struct {
APIServerEndpoint string `yaml:"apiServerEndpoint"`
MetricsAddr string `yaml:"metricsAddr"`
ProbeAddr string `yaml:"probeAddr"`
EnableLeaderElection bool `yaml:"enableLeaderElection"`
MaxConcurrentReconciles int `yaml:"maxConcurrentReconciles"`
ProvisioningTimeout time.Duration `yaml:"provisioningTimeout"`
}
Config holds the controller configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a config with default values.
func LoadConfig ¶
LoadConfig loads configuration from a YAML file.
type DefaultReachabilityChecker ¶
DefaultReachabilityChecker implements ReachabilityChecker using TCP dial. When the Machine has a bastion configured, it first establishes an SSH connection to the bastion and then TCP-dials the target through the tunnel.
func (*DefaultReachabilityChecker) CheckReachable ¶
func (c *DefaultReachabilityChecker) CheckReachable(ctx context.Context, machine *unboundedv1alpha3.Machine) error
CheckReachable checks if the machine is reachable via TCP. For machines behind a bastion, the probe is routed through the bastion's SSH tunnel. For direct machines, a plain TCP dial is performed.
type MachineProvisioner ¶
type MachineProvisioner interface {
ProvisionMachine(ctx context.Context, machine *unboundedv1alpha3.Machine, sshConfig *ssh.ClientConfig, bootstrapToken string, clusterInfo *ClusterInfo) error
}
MachineProvisioner handles the actual provisioning of a machine via SSH.
type MachineReconciler ¶
type MachineReconciler struct {
client.Client
Scheme *runtime.Scheme
ReachabilityChecker ReachabilityChecker
Provisioner MachineProvisioner
ClusterInfo *ClusterInfo
MaxConcurrentReconciles int
ProvisioningTimeoutDuration time.Duration
}
MachineReconciler reconciles a Machine object.
func (*MachineReconciler) Reconcile ¶
Reconcile handles Machine reconciliation: reachability checks and provisioning.
func (*MachineReconciler) SetupWithManager ¶
func (r *MachineReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type ReachabilityChecker ¶
type ReachabilityChecker interface {
CheckReachable(ctx context.Context, machine *unboundedv1alpha3.Machine) error
}
ReachabilityChecker checks if a machine is reachable via TCP. When a bastion is configured, the check dials through the bastion's SSH tunnel to probe the target; otherwise a direct TCP dial is used.