diff --git a/hack/jenkins/release_build_and_upload.sh b/hack/jenkins/release_build_and_upload.sh index 1d78ab744c8d..c42698d7926d 100755 --- a/hack/jenkins/release_build_and_upload.sh +++ b/hack/jenkins/release_build_and_upload.sh @@ -39,7 +39,8 @@ grep -E "^VERSION_BUILD \\?=" Makefile | grep "${VERSION_BUILD}" # Force go packages to the Jekins home directory export GOPATH=$HOME/go - +# Make sure docker is installed and configured +./hack/jenkins/installers/check_install_docker.sh # Verify ISO exists echo "Verifying ISO exists ..." make verify-iso @@ -111,5 +112,20 @@ fi #echo "Updating Docker images ..." #make push-gvisor-addon-image push-storage-provisioner-manifest +echo "Generating tarball for docker images" +# first get the correct tag of the kic base image +KIC_VERSION=$(grep -E "Version =" pkg/drivers/kic/types.go | cut -d \" -f 2 | cut -d "-" -f 1) +# then generate tarballs for all achitectures +for ARCH in "amd64" "arm64" "arm/v7" "ppc64le" "s390x" +do + SUFFIX=$(echo $ARCH | sed 's/\///g') + IMAGE_NAME=kicbase/stable:${KIC_VERSION} + TARBALL_NAME=out/kicbase-${KIC_VERSION}-${SUFFIX}.tar + docker pull ${IMAGE_NAME} --platform linux/${ARCH} + docker image save ${IMAGE_NAME} -o ${TARBALL_NAME} + openssl sha256 "${TARBALL_NAME}" | awk '{print $2}' > "${TARBALL_NAME}.sha256" + docker rmi -f ${IMAGE_NAME} +done + echo "Updating latest bucket for ${VERSION} release ..." gsutil cp -r "gs://${BUCKET}/releases/${TAGNAME}/*" "gs://${BUCKET}/releases/latest/" diff --git a/pkg/minikube/download/download.go b/pkg/minikube/download/download.go index a4404cbf458e..27289bfedce4 100644 --- a/pkg/minikube/download/download.go +++ b/pkg/minikube/download/download.go @@ -65,7 +65,7 @@ func CreateDstDownloadMock(_, dst string) error { } // download is a well-configured atomic download function -func download(src, dst string) error { +func download(src, dst string, options ...getter.ClientOption) error { var clientOptions []getter.ClientOption if out.IsTerminal(os.Stdout) && !detect.GithubActionRunner() { progress := getter.WithProgress(DefaultProgressBar) @@ -76,6 +76,7 @@ func download(src, dst string) error { } else { clientOptions = []getter.ClientOption{} } + clientOptions = append(clientOptions, options...) tmpDst := dst + ".download" client := &getter.Client{ Src: src, diff --git a/pkg/minikube/download/image.go b/pkg/minikube/download/image.go index b099e71834f4..5f970538cd6b 100644 --- a/pkg/minikube/download/image.go +++ b/pkg/minikube/download/image.go @@ -32,6 +32,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/daemon" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/tarball" + "github.com/hashicorp/go-getter" "github.com/pkg/errors" "k8s.io/klog/v2" "k8s.io/minikube/pkg/minikube/detect" @@ -39,6 +40,7 @@ import ( "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/out/register" + "k8s.io/minikube/pkg/version" ) var ( @@ -224,6 +226,50 @@ func ImageToCache(img string) error { } } +func DownloadImageFromGithubToCache(img string, imgVersion string) (string, error) { + f := imagePathInCache(img) + fileLock := f + ".lock" + + kicbaseArch := runtime.GOARCH + if kicbaseArch == "arm" { + kicbaseArch = "armv7" + } + + releaser, err := lockDownload(fileLock) + if err != nil { + return "", err + } + if releaser != nil { + defer releaser.Release() + } + downloadURL := fmt.Sprintf("https://github.com/kubernetes/minikube/releases/download/%s/%s-%s-%s.tar", + version.GetVersion(), + img, imgVersion, kicbaseArch) + // if we reach here, that means the user cannot have access to any docker registry + // this means the user is very likely to have a network issue + // downloading from github via http is the last resort, and we should remind the user + // that he should at least get access to github + // print essential warnings + out.WarningT("minikube cannot pull kicbase image from any docker registry, and is trying to download kicbase tarball from github release page via HTTP.") + out.Ln("The url to the tarball is %s", downloadURL) + out.WarningT("It's very likely that you have an internet issue. Please ensure that you can access the internet at least via HTTP, directly or with proxy. Currently your proxy configure is:") + envs := []string{"HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy", "ALL_PROXY", "NO_PROXY"} + for _, env := range envs { + if v := os.Getenv(env); v != "" { + out.Infof("{{.env}}={{.value}}", out.V{"env": env, "value": v}) + } + } + out.Ln("") + + // we don't want the tarball to be decompressed + // so we pass client options to suppress this behavior + if err := download(downloadURL, f, getter.WithDecompressors(map[string]getter.Decompressor{})); err != nil { + return "", err + } + return downloadURL, nil + +} + func parseImage(img string) (*name.Tag, name.Reference, error) { var ref name.Reference diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 6feffc855763..1a57c3786dfc 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -133,12 +133,13 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down if finalImg != "" { cc.KicBaseImage = finalImg if image.Tag(finalImg) != image.Tag(baseImg) { - out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s as a fallback image", image.Tag(baseImg), image.Tag(finalImg))) + out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s as a fallback image", image.Tag(baseImg), finalImg)) } } }() + // first we try to download the kicbase image (and fall back images) from docker registry + var err error for _, img := range append([]string{baseImg}, kic.FallbackImages...) { - var err error if driver.IsDocker(cc.Driver) && download.ImageExistsInDaemon(img) && !downloadOnly { klog.Infof("%s exists in daemon, skipping load", img) @@ -167,7 +168,23 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down } klog.Infof("failed to download %s, will try fallback image if available: %v", img, err) } - return fmt.Errorf("failed to download kic base image or any fallback image") + // second if we failed to download any fallback image + // that means probably all registries are blocked by network issues + // we can try to download the image from minikube release page + kicbaseVersion := strings.Split(kic.Version, "-")[0] + finalImg, err = download.DownloadImageFromGithubToCache("kicbase", kicbaseVersion) + if err != nil { + klog.Infof("failed to download %s", finalImg) + return fmt.Errorf("failed to download kic base image or any fallback image") + } + klog.Infof("successfully downloaded %s as fall back image", finalImg) + if !downloadOnly && driver.IsDocker(cc.Driver) { + if finalImg, err = download.CacheToDaemon("kicbase"); err == nil { + klog.Infof("successfully loaded and using kicbase from tarball on github") + } + } + return nil + }) }