Skip to content

Commit

Permalink
Merge pull request #7943 from medyagh/kicbase_gh_package
Browse files Browse the repository at this point in the history
docker/podman: add alternative image repo for base image to fallback
  • Loading branch information
medyagh authored May 4, 2020
2 parents 59adfbc + 041a452 commit ca53537
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pkg/drivers/kic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ca53537

Please sign in to comment.