mirror of
https://github.com/rancher/rke.git
synced 2025-08-25 18:08:43 +00:00
Merge pull request #300 from moelsayed/prepull_images
Pre-pull k8s images
This commit is contained in:
commit
c11ef66eab
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/rancher/rke/services"
|
"github.com/rancher/rke/services"
|
||||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"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")
|
log.Infof(ctx, "[sync] Successfully synced nodes Labels and Taints")
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
@ -78,6 +78,10 @@ func ClusterUp(
|
|||||||
return APIURL, caCrt, clientCert, clientKey, err
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := kubeCluster.PrePullK8sImages(ctx); err != nil {
|
||||||
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
|
}
|
||||||
|
|
||||||
err = kubeCluster.DeployControlPlane(ctx)
|
err = kubeCluster.DeployControlPlane(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return APIURL, caCrt, clientCert, clientKey, err
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
|
Loading…
Reference in New Issue
Block a user