diff --git a/nodeadm/cmd/nodeadm/init/init.go b/nodeadm/cmd/nodeadm/init/init.go index febb1159c..99f054ec1 100644 --- a/nodeadm/cmd/nodeadm/init/init.go +++ b/nodeadm/cmd/nodeadm/init/init.go @@ -2,6 +2,7 @@ package init import ( "context" + "time" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" @@ -46,6 +47,8 @@ func (c *initCmd) Flaggy() *flaggy.Subcommand { } func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error { + start := time.Now() + log.Info("Checking user is root..") root, err := cli.IsRunningAsRoot() if err != nil { @@ -139,6 +142,8 @@ func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error { } } + log.Info("done!", zap.Duration("duration", time.Since(start))) + return nil } diff --git a/nodeadm/internal/kubelet/version.go b/nodeadm/internal/kubelet/version.go index 7ee011637..e52fd3769 100644 --- a/nodeadm/internal/kubelet/version.go +++ b/nodeadm/internal/kubelet/version.go @@ -1,6 +1,8 @@ package kubelet import ( + "errors" + "os" "os/exec" "regexp" ) @@ -10,17 +12,19 @@ func GetKubeletVersion() (string, error) { if err != nil { return "", err } - version := parseSemVer(*rawVersion) + version := parseSemVer(string(rawVersion)) return version, nil } -func GetKubeletVersionRaw() (*string, error) { - output, err := exec.Command("kubelet", "--version").Output() - if err != nil { +const kubeletVersionFile = "/etc/eks/kubelet-version.txt" + +func GetKubeletVersionRaw() ([]byte, error) { + if _, err := os.Stat(kubeletVersionFile); errors.Is(err, os.ErrNotExist) { + return exec.Command("kubelet", "--version").Output() + } else if err != nil { return nil, err } - rawVersion := string(output) - return &rawVersion, nil + return os.ReadFile(kubeletVersionFile) } var semVerRegex = regexp.MustCompile(`v[0-9]+\.[0-9]+.[0-9]+`) diff --git a/templates/al2023/provisioners/install-worker.sh b/templates/al2023/provisioners/install-worker.sh index 212e3683d..6c6540a86 100644 --- a/templates/al2023/provisioners/install-worker.sh +++ b/templates/al2023/provisioners/install-worker.sh @@ -187,6 +187,9 @@ done sudo rm ./*.sha256 +kubelet --version > "${WORKING_DIR}/kubelet-version.txt" +sudo mv "${WORKING_DIR}/kubelet-version.txt" /etc/eks/kubelet-version.txt + ################################################################################ ### ECR Credential Provider Binary ############################################# ################################################################################