61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"context"
|
|
|
|
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
|
"undecided.project/monok8s/pkg/node"
|
|
"undecided.project/monok8s/pkg/system"
|
|
)
|
|
|
|
type Runner struct {
|
|
NodeCtx *node.NodeContext
|
|
Registry *Registry
|
|
}
|
|
|
|
func NewRunner(cfg *monov1alpha1.MonoKSConfig) *Runner {
|
|
runnerCfg := system.RunnerConfig{}
|
|
nctx := &node.NodeContext{
|
|
Config: cfg,
|
|
SystemRunner: system.NewRunner(runnerCfg),
|
|
}
|
|
return &Runner{
|
|
NodeCtx: nctx,
|
|
Registry: NewRegistry(nctx),
|
|
}
|
|
}
|
|
|
|
func (r *Runner) Init(ctx context.Context) error {
|
|
for _, name := range []string{
|
|
"configure_hostname",
|
|
"configure_dns",
|
|
"configure_mgmt_interface",
|
|
"validate_network_requirements",
|
|
"configure_default_cni",
|
|
"start_crio",
|
|
"check_container_images",
|
|
"wait_for_existing_cluster_if_needed",
|
|
"decide_bootstrap_action",
|
|
"check_required_images",
|
|
"generate_kubeadm_config",
|
|
"run_kubeadm_init",
|
|
"restart_kubelet",
|
|
"apply_local_node_metadata_if_possible",
|
|
"allow_single_node_scheduling",
|
|
"print_summary",
|
|
} {
|
|
if err := r.RunNamedStep(ctx, name); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (r *Runner) RunNamedStep(ctx context.Context, name string) error {
|
|
step, err := r.Registry.Get(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return step(ctx, r.NodeCtx)
|
|
}
|