1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-25 09:58:34 +00:00

Merge pull request #300 from moelsayed/prepull_images

Pre-pull k8s images
This commit is contained in:
Alena Prokharchyk 2018-02-01 14:11:38 -08:00 committed by GitHub
commit c11ef66eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/rancher/rke/services"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
"gopkg.in/yaml.v2"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
@ -279,3 +280,20 @@ func (c *Cluster) SyncLabelsAndTaints(ctx context.Context) error {
log.Infof(ctx, "[sync] Successfully synced nodes Labels and Taints")
return nil
}
func (c *Cluster) PrePullK8sImages(ctx context.Context) error {
log.Infof(ctx, "Pre-pulling kubernetes images")
var errgrp errgroup.Group
hosts := c.getUniqueHostList()
for _, host := range hosts {
runHost := host
errgrp.Go(func() error {
return docker.UseLocalOrPull(ctx, runHost.DClient, runHost.Address, c.SystemImages.Kubernetes, "pre-deploy", c.PrivateRegistriesMap)
})
}
if err := errgrp.Wait(); err != nil {
return err
}
log.Infof(ctx, "Kubernetes images pulled successfully")
return nil
}

View File

@ -78,6 +78,10 @@ func ClusterUp(
return APIURL, caCrt, clientCert, clientKey, err
}
if err := kubeCluster.PrePullK8sImages(ctx); err != nil {
return APIURL, caCrt, clientCert, clientKey, err
}
err = kubeCluster.DeployControlPlane(ctx)
if err != nil {
return APIURL, caCrt, clientCert, clientKey, err