From c03d1a330b7fc870237a89d6b9d9e92d7aa3cffd Mon Sep 17 00:00:00 2001 From: kun zhou Date: Wed, 16 Oct 2024 22:01:22 -0700 Subject: [PATCH] modify bootstrap script for 1.31 cluster --- .../internal/cloudinit/kubeadm-bootstrap-script.sh | 12 ++++-------- .../internal/controllers/kubeadmconfig_controller.go | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/bootstrap/kubeadm/internal/cloudinit/kubeadm-bootstrap-script.sh b/bootstrap/kubeadm/internal/cloudinit/kubeadm-bootstrap-script.sh index 5c78238ce0ac..4a3aa5d0d860 100644 --- a/bootstrap/kubeadm/internal/cloudinit/kubeadm-bootstrap-script.sh +++ b/bootstrap/kubeadm/internal/cloudinit/kubeadm-bootstrap-script.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2020 The Kubernetes Authors. +# Copyright 2024 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -106,7 +106,6 @@ function retry-command() { fi } -# {{ if .ControlPlane }} function try-or-die-command() { local kubeadm_return log::info "running '$*'" @@ -118,7 +117,6 @@ function try-or-die-command() { log::error_exit "fatal error, exiting" "${kubeadm_return}" fi } -# {{ end }} retry-command kubeadm join phase preflight --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests # {{ if .ControlPlane }} @@ -128,10 +126,8 @@ retry-command kubeadm join phase control-plane-prepare kubeconfig retry-command kubeadm join phase control-plane-prepare control-plane # {{ end }} retry-command kubeadm join phase kubelet-start -# {{ if .ControlPlane }} -try-or-die-command kubeadm join phase control-plane-join etcd -retry-command kubeadm join phase control-plane-join update-status -retry-command kubeadm join phase control-plane-join mark-control-plane -# {{ end }} + +# Run kubeadm join and skip all already executed phases. +try-or-die-command kubeadm join --skip-phases preflight,control-plane-prepare,kubelet-start log::success_exit diff --git a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go index 16f150a3bf12..49387855ecd6 100644 --- a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go +++ b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go @@ -590,6 +590,7 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope) DiskSetup: scope.Config.Spec.DiskSetup, KubeadmVerbosity: verbosityFlag, UseExperimentalRetry: scope.Config.Spec.UseExperimentalRetryJoin, + KubernetesVersion: parsedVersion, }, JoinConfiguration: joinData, }