Added kubeadm init

This commit is contained in:
2026-03-30 01:31:38 +08:00
parent 5fbc2846a1
commit 210fabdcc6
7 changed files with 419 additions and 102 deletions

View File

@@ -22,29 +22,29 @@ func NewRegistry(ctx *node.NodeContext) *Registry {
return &Registry{
steps: map[string]node.Step{
"validate_network_requirements": node.ValidateNetworkRequirements,
"detect_local_cluster_state": node.DetectLocalClusterState,
"classify_bootstrap_action": node.ClassifyBootstrapAction,
"configure_default_cni": node.ConfigureDefaultCNI,
"start_crio": node.StartCRIO,
"wait_for_existing_cluster_if_needed": node.WaitForExistingClusterIfNeeded,
"validate_required_images": node.ValidateRequiredImagesPresent,
"generate_kubeadm_config": node.GenerateKubeadmConfig,
"run_kubeadm_init": node.RunKubeadmInit,
"apply_local_node_metadata_if_possible": node.ApplyLocalNodeMetadataIfPossible,
"allow_single_node_scheduling": node.AllowSingleNodeScheduling,
"ensure_ip_forward": node.EnsureIPForward,
"configure_hostname": node.ConfigureHostname(netCfg),
"configure_mgmt_interface": node.ConfigureMgmtInterface(netCfg),
"configure_dns": node.ConfigureDNS(netCfg),
"set_hostname_if_needed": node.SetHostnameIfNeeded,
"print_summary": node.PrintSummary,
"reconcile_control_plane": node.ReconcileControlPlane,
"check_upgrade_prereqs": node.CheckUpgradePrereqs,
"run_kubeadm_upgrade_apply": node.RunKubeadmUpgradeApply,
"run_kubeadm_join": node.RunKubeadmJoin,
"reconcile_node": node.ReconcileNode,
"run_kubeadm_upgrade_node": node.RunKubeadmUpgradeNode,
"AllowSingleNodeScheduling": node.AllowSingleNodeScheduling,
"ApplyLocalNodeMetadataIfPossible": node.ApplyLocalNodeMetadataIfPossible,
"CheckUpgradePrereqs": node.CheckUpgradePrereqs,
"ClassifyBootstrapAction": node.ClassifyBootstrapAction,
"ConfigureDNS": node.ConfigureDNS(netCfg),
"ConfigureDefaultCNI": node.ConfigureDefaultCNI,
"ConfigureHostname": node.ConfigureHostname(netCfg),
"ConfigureMgmtInterface": node.ConfigureMgmtInterface(netCfg),
"DetectLocalClusterState": node.DetectLocalClusterState,
"EnsureIPForward": node.EnsureIPForward,
"GenerateKubeadmConfig": node.GenerateKubeadmConfig,
"PrintSummary": node.PrintSummary,
"ReconcileControlPlane": node.ReconcileControlPlane,
"ReconcileNode": node.ReconcileNode,
"RunKubeadmInit": node.RunKubeadmInit,
"RunKubeadmJoin": node.RunKubeadmJoin,
"RunKubeadmUpgradeApply": node.RunKubeadmUpgradeApply,
"RunKubeadmUpgradeNode": node.RunKubeadmUpgradeNode,
"SetHostnameIfNeeded": node.SetHostnameIfNeeded,
"StartCRIO": node.StartCRIO,
"ValidateNodeIPAndAPIServerReachability": node.ValidateNodeIPAndAPIServerReachability,
"ValidateRequiredImagesPresent": node.ValidateRequiredImagesPresent,
"WaitForExistingClusterIfNeeded": node.WaitForExistingClusterIfNeeded,
},
}
}

View File

@@ -37,112 +37,107 @@ func NewRunner(cfg *monov1alpha1.MonoKSConfig) *Runner {
Registry: NewRegistry(nctx),
initSteps: []StepInfo{
{
RegKey: "configure_hostname",
RegKey: "ConfigureHostname",
Name: "Configure hostname",
Desc: "Set system hostname according to cluster configuration",
},
{
RegKey: "configure_mgmt_interface",
RegKey: "ConfigureMgmtInterface",
Name: "Configure management interface",
Desc: "Configure management network interface, IP address, and gateway",
},
{
RegKey: "configure_dns",
RegKey: "ConfigureDNS",
Name: "Configure DNS",
Desc: "Set system DNS resolver configuration for cluster and external access",
},
{
RegKey: "ensure_ip_forward",
RegKey: "EnsureIPForward",
Name: "Ensure IP forwarding",
Desc: "Enable kernel IP forwarding required for pod networking",
},
{
RegKey: "configure_default_cni",
RegKey: "ConfigureDefaultCNI",
Name: "Configure default CNI",
Desc: "Install or configure default container networking (CNI bridge, IPAM, etc.)",
},
{
RegKey: "start_crio",
RegKey: "StartCRIO",
Name: "Start CRI-O runtime",
Desc: "Start container runtime and verify it is ready for Kubernetes workloads",
},
{
RegKey: "validate_required_images",
RegKey: "ValidateRequiredImagesPresent",
Name: "Validate required images",
Desc: "Ensure all required Kubernetes images are present or available locally",
},
{
RegKey: "validate_network_requirements",
Name: "Validate network requirements",
Desc: "Ensure required kernel networking features (iptables/nftables, bridge, forwarding) are available",
RegKey: "ValidateNodeIPAndAPIServerReachability",
Name: "Validate Node IP and wether API Server is available",
Desc: "Verify the local ip address with the api server advertise address. Contact remote api server",
},
{
RegKey: "detect_local_cluster_state",
RegKey: "DetectLocalClusterState",
Name: "Detect local cluster state",
Desc: "Inspect local node to determine existing Kubernetes membership and configuration",
},
{
RegKey: "classify_bootstrap_action",
RegKey: "ClassifyBootstrapAction",
Name: "Classify bootstrap action",
Desc: "Decide whether to init, join, upgrade, or reconcile based on local state and desired version",
},
{
RegKey: "wait_for_existing_cluster_if_needed",
RegKey: "WaitForExistingClusterIfNeeded",
Name: "Wait for existing cluster",
Desc: "Block until control plane is reachable when joining or reconciling an existing cluster",
},
{
RegKey: "generate_kubeadm_config",
Name: "Generate kubeadm config",
Desc: "Render kubeadm configuration for init, join, or upgrade operations",
},
{
RegKey: "apply_local_node_metadata_if_possible",
Name: "Apply node metadata",
Desc: "Apply labels/annotations to the local node if API server is reachable",
},
{
RegKey: "allow_single_node_scheduling",
Name: "Allow single-node scheduling",
Desc: "Remove control-plane taints to allow workloads on single-node clusters",
},
{
RegKey: "reconcile_control_plane",
RegKey: "ReconcileControlPlane",
Name: "Reconcile control plane",
Desc: "Ensure control plane components match desired state without full reinitialization",
},
{
RegKey: "check_upgrade_prereqs",
RegKey: "CheckUpgradePrereqs",
Name: "Check upgrade prerequisites",
Desc: "Validate cluster state and version compatibility before upgrade",
},
{
RegKey: "run_kubeadm_upgrade_apply",
RegKey: "RunKubeadmUpgradeApply",
Name: "Run kubeadm upgrade apply",
Desc: "Upgrade control plane components using kubeadm",
},
{
RegKey: "run_kubeadm_init",
RegKey: "RunKubeadmInit",
Name: "Run kubeadm init",
Desc: "Initialize a new Kubernetes control plane using kubeadm",
},
{
RegKey: "run_kubeadm_join",
RegKey: "RunKubeadmJoin",
Name: "Run kubeadm join",
Desc: "Join node to existing cluster as worker or control-plane",
},
{
RegKey: "reconcile_node",
RegKey: "ReconcileNode",
Name: "Reconcile node state",
Desc: "Ensure node configuration matches desired state after join or upgrade",
},
{
RegKey: "run_kubeadm_upgrade_node",
RegKey: "RunKubeadmUpgradeNode",
Name: "Run kubeadm upgrade node",
Desc: "Upgrade node components (kubelet, config) to match control plane",
},
{
RegKey: "print_summary",
RegKey: "ApplyLocalNodeMetadataIfPossible",
Name: "Apply node metadata",
Desc: "Apply labels/annotations to the local node if API server is reachable",
},
{
RegKey: "AllowSingleNodeScheduling",
Name: "Allow single-node scheduling",
Desc: "Remove control-plane taints to allow workloads on single-node clusters",
},
{
RegKey: "PrintSummary",
Name: "Print summary",
Desc: "Output final bootstrap summary and detected state",
},