Matches ctl version to upstream
This commit is contained in:
@@ -1,36 +1,87 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func WaitForExistingClusterIfNeeded(context.Context, *NodeContext) error {
|
||||
klog.Info("wait_for_existing_cluster_if_needed: TODO implement kubelet/admin.conf waits")
|
||||
return nil
|
||||
klog.Info("wait_for_existing_cluster_if_needed: TODO implement kubelet/admin.conf waits")
|
||||
return nil
|
||||
}
|
||||
func CheckRequiredImages(context.Context, *NodeContext) error {
|
||||
klog.Info("check_required_images: TODO implement kubeadm image list + crictl image presence")
|
||||
return nil
|
||||
|
||||
func CheckRequiredImages(ctx context.Context, n *NodeContext) error {
|
||||
if n.Config.Spec.SkipImageCheck {
|
||||
klog.Infof("skipping image check (skipImageCheck=true)")
|
||||
return nil
|
||||
}
|
||||
|
||||
k8sVersion := strings.TrimSpace(n.Config.Spec.KubernetesVersion)
|
||||
if k8sVersion == "" {
|
||||
return fmt.Errorf("kubernetesVersion is required")
|
||||
}
|
||||
|
||||
klog.Infof("checking required Kubernetes images for %s...", k8sVersion)
|
||||
|
||||
result, err := n.SystemRunner.Run(ctx,
|
||||
"kubeadm", "config", "images", "list",
|
||||
"--kubernetes-version", k8sVersion,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("list required Kubernetes images for %s: %w", k8sVersion, err)
|
||||
}
|
||||
|
||||
var missing []string
|
||||
for _, img := range strings.Fields(result.Stdout) {
|
||||
if err := checkImagePresent(ctx, n, img); err != nil {
|
||||
klog.Errorf("MISSING image: %s", img)
|
||||
missing = append(missing, img)
|
||||
continue
|
||||
}
|
||||
klog.Infof("found image: %s", img)
|
||||
}
|
||||
|
||||
if len(missing) > 0 {
|
||||
return fmt.Errorf("preload the Kubernetes images before bootstrapping; missing: %s", strings.Join(missing, ", "))
|
||||
}
|
||||
|
||||
klog.Infof("all required images are present")
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkImagePresent(ctx context.Context, n *NodeContext, image string) error {
|
||||
image = strings.TrimSpace(image)
|
||||
if image == "" {
|
||||
return fmt.Errorf("image is required")
|
||||
}
|
||||
|
||||
// crictl inspecti exits non-zero when the image is absent.
|
||||
_, err := n.SystemRunner.Run(ctx, "crictl", "inspecti", image)
|
||||
if err != nil {
|
||||
return fmt.Errorf("image %q not present: %w", image, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func GenerateKubeadmConfig(context.Context, *NodeContext) error {
|
||||
klog.Info("generate_kubeadm_config: TODO render kubeadm v1beta4 config from MonoKSConfig")
|
||||
return nil
|
||||
klog.Info("generate_kubeadm_config: TODO render kubeadm v1beta4 config from MonoKSConfig")
|
||||
return nil
|
||||
}
|
||||
func RunKubeadmInit(context.Context, *NodeContext) error {
|
||||
klog.Info("run_kubeadm_init: TODO implement kubeadm init --config <file>")
|
||||
return nil
|
||||
klog.Info("run_kubeadm_init: TODO implement kubeadm init --config <file>")
|
||||
return nil
|
||||
}
|
||||
func RunKubeadmUpgradeApply(context.Context, *NodeContext) error {
|
||||
klog.Info("run_kubeadm_upgrade_apply: TODO implement kubeadm upgrade apply")
|
||||
return nil
|
||||
klog.Info("run_kubeadm_upgrade_apply: TODO implement kubeadm upgrade apply")
|
||||
return nil
|
||||
}
|
||||
func RunKubeadmJoin(context.Context, *NodeContext) error {
|
||||
klog.Info("run_kubeadm_join: TODO implement kubeadm join")
|
||||
return nil
|
||||
klog.Info("run_kubeadm_join: TODO implement kubeadm join")
|
||||
return nil
|
||||
}
|
||||
func RunKubeadmUpgradeNode(context.Context, *NodeContext) error {
|
||||
klog.Info("run_kubeadm_upgrade_node: TODO implement kubeadm upgrade node")
|
||||
return nil
|
||||
klog.Info("run_kubeadm_upgrade_node: TODO implement kubeadm upgrade node")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user