Skip to content

Commit

Permalink
Pre-pull images
Browse files Browse the repository at this point in the history
Signed-off-by: Artiom Diomin <kron82@gmail.com>
  • Loading branch information
kron4eg committed Jan 25, 2022
1 parent 2fc80cf commit 68b32cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion pkg/scripts/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ type Data map[string]interface{}
// Render text template with given `variables` Render-context
func Render(cmd string, variables map[string]interface{}) (string, error) {
tpl := template.New("base").
Funcs(sprig.TxtFuncMap()).
Funcs(sprig.TxtFuncMap())

_, err := tpl.New("library").Parse(libraryTemplate)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func saveCABundleOnControlPlane(s *state.State, _ *kubeoneapi.HostConfig, conn s
}

func approvePendingCSR(s *state.State, node *kubeoneapi.HostConfig, conn ssh.Connection) error {
s.Logger.Infof("Looking for CSRs for %q to approve...", node.Hostname)
s.Logger.Infof("Looking for CSRs to approve...")

// Need to wait for the second CSR to appear
time.Sleep(20 * time.Second)
Expand Down
19 changes: 18 additions & 1 deletion pkg/tasks/prerequisites.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
"fmt"
"time"

"github.com/MakeNowJust/heredoc/v2"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

kubeoneapi "k8c.io/kubeone/pkg/apis/kubeone"
"k8c.io/kubeone/pkg/runner"
"k8c.io/kubeone/pkg/scripts"
"k8c.io/kubeone/pkg/ssh"
"k8c.io/kubeone/pkg/state"
Expand All @@ -37,7 +39,22 @@ import (
func installPrerequisites(s *state.State) error {
s.Logger.Infoln("Installing prerequisites...")

return s.RunTaskOnAllNodes(installPrerequisitesOnNode, state.RunParallel)
if err := s.RunTaskOnAllNodes(installPrerequisitesOnNode, state.RunParallel); err != nil {
return fmt.Errorf("failed to install prerequisites: %w", err)
}

return s.RunTaskOnAllNodes(func(ctx *state.State, node *kubeoneapi.HostConfig, conn ssh.Connection) error {
ctx.Logger.Info("Pre-pull images")

_, _, err := ctx.Runner.Run(
heredoc.Doc(`
sudo kubeadm config images pull --kubernetes-version {{ .KUBERNETES_VERSION }}
`), runner.TemplateVariables{
"KUBERNETES_VERSION": ctx.Cluster.Versions.Kubernetes,
})

return err
}, state.RunParallel)
}

func generateConfigurationFiles(s *state.State) error {
Expand Down

0 comments on commit 68b32cb

Please sign in to comment.