Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker/podman: add alternative image repo for base image to fallback #7943

Merged
merged 5 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
medyagh marked this conversation as resolved.
Show resolved Hide resolved
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