diff --git a/pkg/drivers/kic/types.go b/pkg/drivers/kic/types.go index e8692edcc789..2dffa0a1ab1b 100644 --- a/pkg/drivers/kic/types.go +++ b/pkg/drivers/kic/types.go @@ -35,6 +35,10 @@ const ( var ( // BaseImage is the base image is used to spin up kic containers. it uses same base-image as kind. BaseImage = fmt.Sprintf("gcr.io/k8s-minikube/kicbase:%s@sha256:%s", Version, baseImageSHA) + // BaseImageFallBack the fall back of BaseImage in case gcr.io is not available. stored in github packages https://github.com/kubernetes/minikube/packages/206071 + // github packages docker does _NOT_ support pulling by sha as mentioned in the docs: + // https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages + BaseImageFallBack = fmt.Sprintf("docker.pkg.github.com/kubernetes/minikube/kicbase:%s", Version) ) // Config is configuration for the kic driver used by registry diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index ea33c8b7dc63..19d37c9f807d 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/viper" "golang.org/x/sync/errgroup" cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config" + "k8s.io/minikube/pkg/drivers/kic" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/download" @@ -99,14 +100,21 @@ func doCacheBinaries(k8sVersion string) error { } // BeginDownloadKicArtifacts downloads the kic image + preload tarball, returns true if preload is available -func beginDownloadKicArtifacts(g *errgroup.Group, driver string, cRuntime string, baseImage string) { - glog.Infof("Beginning downloading kic artifacts for %s with %s", driver, cRuntime) - if driver == "docker" { - if !image.ExistsImageInDaemon(baseImage) { +func beginDownloadKicArtifacts(g *errgroup.Group, cc *config.ClusterConfig) { + glog.Infof("Beginning downloading kic artifacts for %s with %s", cc.Driver, cc.KubernetesConfig.ContainerRuntime) + if cc.Driver == "docker" { + if !image.ExistsImageInDaemon(cc.KicBaseImage) { out.T(out.Pulling, "Pulling base image ...") g.Go(func() error { - glog.Infof("Downloading %s to local daemon", baseImage) - return image.WriteImageToDaemon(baseImage) + // TODO #8004 : make base-image respect --image-repository + glog.Infof("Downloading %s to local daemon", cc.KicBaseImage) + err := image.WriteImageToDaemon(cc.KicBaseImage) + if err != nil { + glog.Infof("failed to download base-image %q will try to download the fallback base-image %q instead.", cc.KicBaseImage, kic.BaseImageFallBack) + cc.KicBaseImage = kic.BaseImageFallBack + return image.WriteImageToDaemon(kic.BaseImageFallBack) + } + return nil }) } } else { diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 95a666ec0760..ceee28d23adb 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -197,7 +197,7 @@ func Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool) (comman } if driver.IsKIC(cc.Driver) { - beginDownloadKicArtifacts(&kicGroup, cc.Driver, cc.KubernetesConfig.ContainerRuntime, cc.KicBaseImage) + beginDownloadKicArtifacts(&kicGroup, cc) } if !driver.BareMetal(cc.Driver) {