From 7914d057d1f5bfd81ea6a01882916c3a193067bd Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 29 Apr 2020 23:09:20 -0700 Subject: [PATCH 1/5] fall back to github if gcr.io is not available --- pkg/drivers/kic/types.go | 4 ++++ pkg/minikube/node/cache.go | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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..3b7069a39180 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" @@ -106,7 +107,14 @@ func beginDownloadKicArtifacts(g *errgroup.Group, driver string, cRuntime string out.T(out.Pulling, "Pulling base image ...") g.Go(func() error { glog.Infof("Downloading %s to local daemon", baseImage) - return image.WriteImageToDaemon(baseImage) + err := image.WriteImageToDaemon(baseImage) + if err != nil { + // registry/driver package uses viper.Set + viper.Set("base-image", kic.BaseImageFallBack) + glog.Infof("failed to download %s will try to download the fallback image from %s", baseImage, kic.BaseImageFallBack) + return image.WriteImageToDaemon(kic.BaseImageFallBack) + } + return nil }) } } else { From 1ee8cabd6f666392461baaadfd56bbe3c3d093e7 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 30 Apr 2020 00:00:20 -0700 Subject: [PATCH 2/5] add TODO with issue link --- pkg/minikube/node/cache.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 3b7069a39180..cb3a4a1ab25e 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -109,7 +109,8 @@ func beginDownloadKicArtifacts(g *errgroup.Group, driver string, cRuntime string glog.Infof("Downloading %s to local daemon", baseImage) err := image.WriteImageToDaemon(baseImage) if err != nil { - // registry/driver package uses viper.Set + // TODO : remove this global set when this issue is closed + // https://github.com/kubernetes/minikube/issues/7944 viper.Set("base-image", kic.BaseImageFallBack) glog.Infof("failed to download %s will try to download the fallback image from %s", baseImage, kic.BaseImageFallBack) return image.WriteImageToDaemon(kic.BaseImageFallBack) From 7654c1b058748d0158776eb55cf82589244ce730 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 13:22:48 -0700 Subject: [PATCH 3/5] address review comments --- pkg/minikube/node/cache.go | 19 +++++++++---------- pkg/minikube/node/start.go | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index cb3a4a1ab25e..d149d1d2a120 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -100,19 +100,18 @@ 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) - err := image.WriteImageToDaemon(baseImage) + glog.Infof("Downloading %s to local daemon", cc.KicBaseImage) + err := image.WriteImageToDaemon(cc.KicBaseImage) if err != nil { - // TODO : remove this global set when this issue is closed - // https://github.com/kubernetes/minikube/issues/7944 - viper.Set("base-image", kic.BaseImageFallBack) - glog.Infof("failed to download %s will try to download the fallback image from %s", baseImage, kic.BaseImageFallBack) + origImage := cc.KicBaseImage + cc.KicBaseImage = kic.BaseImageFallBack + glog.Infof("failed to download base image %q will try to download the fallback image %q instead.", origImage, kic.BaseImageFallBack) return image.WriteImageToDaemon(kic.BaseImageFallBack) } return nil 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) { From 0189b10624c4a88afe843881ef3fd4a07e8ea449 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 13:47:07 -0700 Subject: [PATCH 4/5] improve log --- pkg/minikube/node/cache.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index d149d1d2a120..ef34b440a2fe 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -109,9 +109,8 @@ func beginDownloadKicArtifacts(g *errgroup.Group, cc *config.ClusterConfig) { glog.Infof("Downloading %s to local daemon", cc.KicBaseImage) err := image.WriteImageToDaemon(cc.KicBaseImage) if err != nil { - origImage := cc.KicBaseImage + 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 - glog.Infof("failed to download base image %q will try to download the fallback image %q instead.", origImage, kic.BaseImageFallBack) return image.WriteImageToDaemon(kic.BaseImageFallBack) } return nil From 041a452a16c86a4ce9b493332eae77c31aaecad7 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 15:22:50 -0700 Subject: [PATCH 5/5] add todo comment --- pkg/minikube/node/cache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index ef34b440a2fe..19d37c9f807d 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -106,6 +106,7 @@ func beginDownloadKicArtifacts(g *errgroup.Group, cc *config.ClusterConfig) { if !image.ExistsImageInDaemon(cc.KicBaseImage) { out.T(out.Pulling, "Pulling base image ...") g.Go(func() error { + // 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 {