From 1f6e140e005db1fdfaf7f1e2df2f394f68be229f Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 4 Jun 2020 12:23:14 -0700 Subject: [PATCH 01/13] try to save image as tarball on download-only --- cmd/minikube/cmd/start.go | 5 +++++ go.mod | 6 +++--- go.sum | 7 +++++++ pkg/minikube/image/image.go | 6 ++++++ pkg/minikube/node/cache.go | 22 +++++++++++++++++----- pkg/minikube/node/start.go | 2 +- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index d831876bdc..2f39dca525 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -613,6 +613,11 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) { exit.WithCodeT(exit.Unavailable, "The driver '{{.driver}}' is not supported on {{.os}}", out.V{"driver": name, "os": runtime.GOOS}) } + // if we are only downloading artifacts for a driver, we can stop validation here + if viper.GetBool("download-only") { + return + } + st := ds.State glog.Infof("status for %s: %+v", name, st) diff --git a/go.mod b/go.mod index 4aa16d86a2..b7df0bc7a6 100644 --- a/go.mod +++ b/go.mod @@ -92,9 +92,9 @@ require ( gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect gopkg.in/yaml.v2 v2.2.8 gotest.tools/v3 v3.0.2 // indirect - k8s.io/api v0.17.3 - k8s.io/apimachinery v0.17.3 - k8s.io/client-go v0.17.3 + k8s.io/api v0.17.4 + k8s.io/apimachinery v0.17.4 + k8s.io/client-go v0.17.4 k8s.io/kubectl v0.0.0 k8s.io/kubernetes v1.17.3 k8s.io/utils v0.0.0-20200229041039-0a110f9eb7ab // indirect diff --git a/go.sum b/go.sum index 6b690e4223..f9f61f4369 100644 --- a/go.sum +++ b/go.sum @@ -359,6 +359,7 @@ github.com/google/cadvisor v0.35.0/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-containerregistry v0.0.0-20200131185320-aec8da010de2 h1:/z0FoA29APs30PljxT6GoZQekF5c1cYhow2osFsj1XU= github.com/google/go-containerregistry v0.0.0-20200131185320-aec8da010de2/go.mod h1:Wtl/v6YdQxv397EREtzwgd9+Ud7Q5D8XMbi3Zazgkrs= @@ -544,6 +545,7 @@ github.com/maruel/panicparse v1.5.0/go.mod h1:aOutY/MUjdj80R0AEVI9qE2zHqig+67t2f github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -551,6 +553,7 @@ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= @@ -817,6 +820,7 @@ github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238/go.mod h1:JwQJCMWpUDqjZrB5jpw0f5VbN7U95zxFy1ZDpoEarGo= +github.com/vdemeester/k8s-pkg-credentialprovider v1.17.4/go.mod h1:inCTmtUdr5KJbreVojo06krnTgaeAz/Z7lynpPk/Q2c= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vishvananda/netlink v1.0.0 h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCOJgSM= github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= @@ -968,6 +972,7 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1016,9 +1021,11 @@ golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200115165105-de0b1760071a h1:bEJ3JL2YUH3tt9KX9dsy0WUF3WOrhjtNjK93o0svepY= golang.org/x/tools v0.0.0-20200115165105-de0b1760071a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200210192313-1ace956b0e17/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index ea966eabaf..1307ed13a6 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -135,6 +135,12 @@ func WriteImageToDaemon(img string) error { return nil } +// Tarball writes the img to a tarball in the minikube cache +func Tarball(img string) error { + + return nil +} + func retrieveImage(ref name.Reference) (v1.Image, error) { glog.Infof("retrieving image: %+v", ref) img, err := daemon.Image(ref) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index cae0144d7c..850e7980cd 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -102,7 +102,7 @@ func doCacheBinaries(k8sVersion string) error { } // beginDownloadKicBaseImage downloads the kic image -func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig) { +func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, downloadOnly bool) { if cc.Driver != "docker" { // TODO: driver == "podman" glog.Info("Driver isn't docker, skipping base image download") @@ -117,17 +117,29 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig) { out.T(out.Pulling, "Pulling base image ...") g.Go(func() error { // TODO #8004 : make base-image respect --image-repository + var finalImg string + // If we end up using a fallback image, notify the user + defer func() { + if finalImg != "" && finalImg != cc.KicBaseImage { + out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s\n minikube will use %s as a fallback image", image.Tag(cc.KicBaseImage), image.Tag(finalImg), image.Tag(finalImg))) + cc.KicBaseImage = finalImg + } + }() for _, img := range append([]string{cc.KicBaseImage}, kic.FallbackImages...) { glog.Infof("Downloading %s to local daemon", img) err := image.WriteImageToDaemon(img) if err == nil { - if img != cc.KicBaseImage { - out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s\n minikube will use %s as a fallback image", image.Tag(cc.KicBaseImage), image.Tag(img), image.Tag(img))) - cc.KicBaseImage = img - } glog.Infof("successfully downloaded %s", img) + finalImg = img return nil } + if downloadOnly { + if err := image.Tarball(img); err == nil { + glog.Infof("successfully saved %s as a tarball", img) + finalImg = img + return nil + } + } glog.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") diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 383df8c062..810b7a1054 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -195,7 +195,7 @@ func Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool) (comman } if driver.IsKIC(cc.Driver) { - beginDownloadKicBaseImage(&kicGroup, cc) + beginDownloadKicBaseImage(&kicGroup, cc, viper.GetBool("download-only")) } if !driver.BareMetal(cc.Driver) { From c629b9b81c8957cd833fad4ea9327c3ccd2fb423 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 4 Jun 2020 12:40:19 -0700 Subject: [PATCH 02/13] load from tarball if cached kic image exists --- pkg/minikube/image/image.go | 26 ++++++++++++++++++++------ pkg/minikube/node/cache.go | 7 ++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index 1307ed13a6..ea50384699 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -34,8 +34,10 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "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/pkg/errors" "k8s.io/minikube/pkg/minikube/constants" + "k8s.io/minikube/pkg/minikube/localpath" ) var defaultPlatform = v1.Platform{ @@ -94,6 +96,24 @@ func ExistsImageInDaemon(img string) bool { return false } +// LoadFromTarball checks if the image exists as a tarball and tries to load it to the local daemon +func LoadFromTarball(img string) error { + p := filepath.Join(constants.ImageCacheDir, img) + p = localpath.SanitizeCacheDir(p) + + tag, err := name.NewTag(img) + if err != nil { + return errors.Wrap(err, "tag") + } + + i, err := tarball.ImageFromPath(p, &tag) + _, err = daemon.Write(tag, i) + if err != nil { + return errors.Wrap(err, "writing daemon image") + } + return nil +} + // Tag returns just the image with the tag // eg image:tag@sha256:digest -> image:tag if there is an associated tag // if not possible, just return the initial img @@ -135,12 +155,6 @@ func WriteImageToDaemon(img string) error { return nil } -// Tarball writes the img to a tarball in the minikube cache -func Tarball(img string) error { - - return nil -} - func retrieveImage(ref name.Reference) (v1.Image, error) { glog.Infof("retrieving image: %+v", ref) img, err := daemon.Image(ref) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 850e7980cd..0760209442 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -126,6 +126,11 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down } }() for _, img := range append([]string{cc.KicBaseImage}, kic.FallbackImages...) { + if err := image.LoadFromTarball(img); err == nil { + glog.Infof("successfully loaded %s from cached tarball", img) + finalImg = img + return nil + } glog.Infof("Downloading %s to local daemon", img) err := image.WriteImageToDaemon(img) if err == nil { @@ -134,7 +139,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down return nil } if downloadOnly { - if err := image.Tarball(img); err == nil { + if err := image.SaveToDir([]string{img}, constants.ImageCacheDir); err == nil { glog.Infof("successfully saved %s as a tarball", img) finalImg = img return nil From de7ea0b270018cb23805cf9dfda8173fbba748b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 7 Jun 2020 17:17:53 +0200 Subject: [PATCH 03/13] Upgrade crio to 1.18.1 --- deploy/iso/minikube-iso/package/crio-bin/conmon-config.h | 9 --------- deploy/iso/minikube-iso/package/crio-bin/crio-bin.hash | 2 ++ deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) delete mode 100755 deploy/iso/minikube-iso/package/crio-bin/conmon-config.h diff --git a/deploy/iso/minikube-iso/package/crio-bin/conmon-config.h b/deploy/iso/minikube-iso/package/crio-bin/conmon-config.h deleted file mode 100755 index 1783492d0d..0000000000 --- a/deploy/iso/minikube-iso/package/crio-bin/conmon-config.h +++ /dev/null @@ -1,9 +0,0 @@ - -#if !defined(CONFIG_H) -#define CONFIG_H - -#define BUF_SIZE 8192 -#define STDIO_BUF_SIZE 8192 -#define DEFAULT_SOCKET_PATH "/var/run/crio" - -#endif // CONFIG_H diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.hash b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.hash index d0f12d3d77..baddc429e9 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.hash +++ b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.hash @@ -12,3 +12,5 @@ sha256 05f9614c4d5970b4662499b84c270b0ab953596ee863dcd09c9dc7a2d2f09789 v1.16.0. sha256 57e1ee990ef2d5af8b32c33a21b4998682608e3556dcf1d3349666f55e7d95b9 v1.16.1.tar.gz sha256 23a797762e4544ee7c171ef138cfc1141a3f0acc2838d9965c2a58e53b16c3ae v1.17.0.tar.gz sha256 7967e9218fdfb59d6005a9e19c1668469bc5566c2a35927cffe7de8656bb22c7 v1.17.1.tar.gz +sha256 865ded95aceb3a33a391b252522682de6b37b39498704c490b3a321dbefaafcb v1.18.0.tar.gz +sha256 794ddc36c2a20fde91fc6cc2c6f02ebdaea85c69b51b67f3994090dbbdbc2a50 v1.18.1.tar.gz diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk index f1a58a31b7..231ae37866 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk +++ b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk @@ -4,8 +4,8 @@ # ################################################################################ -CRIO_BIN_VERSION = v1.17.1 -CRIO_BIN_COMMIT = ee2de87bd8e2a7a84799476cb4fc4ce8a78fdf6d +CRIO_BIN_VERSION = v1.18.1 +CRIO_BIN_COMMIT = 5cbf694c34f8d1af19eb873e39057663a4830635 CRIO_BIN_SITE = https://github.com/cri-o/cri-o/archive CRIO_BIN_SOURCE = $(CRIO_BIN_VERSION).tar.gz CRIO_BIN_DEPENDENCIES = host-go libgpgme From f19ca1597cfe41e7042b601274f5123c7badd2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 7 Jun 2020 17:18:15 +0200 Subject: [PATCH 04/13] Upgrade crio.conf to version v1.18.1 --- .../minikube-iso/package/crio-bin/crio.conf | 97 ++++++++++++------ .../package/crio-bin/crio.conf.default | 99 +++++++++++++------ 2 files changed, 135 insertions(+), 61 deletions(-) diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio.conf b/deploy/iso/minikube-iso/package/crio-bin/crio.conf index 36dc1725ea..efbfae47d6 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio.conf +++ b/deploy/iso/minikube-iso/package/crio-bin/crio.conf @@ -35,8 +35,15 @@ storage_driver = "overlay" # the kubelet. The log directory specified must be an absolute directory. log_dir = "/var/log/crio/pods" -# Location for CRI-O to lay down the version file -version_file = "/var/lib/crio/version" +# Location for CRI-O to lay down the temporary version file. +# It is used to check if crio wipe should wipe containers, which should +# always happen on a node reboot +version_file = "/var/run/crio/version" + +# Location for CRI-O to lay down the persistent version file. +# It is used to check if crio wipe should wipe images, which should +# only happen when CRI-O has been upgraded +version_file_persist = "/var/lib/crio/version" # The crio.api table contains settings for the kubelet/gRPC interface. [crio.api] @@ -44,13 +51,11 @@ version_file = "/var/lib/crio/version" # Path to AF_LOCAL socket on which CRI-O will listen. listen = "/var/run/crio/crio.sock" -# Host IP considered as the primary IP to use by CRI-O for things such as host network IP. -host_ip = "" - # IP address on which the stream server will listen. stream_address = "127.0.0.1" -# The port on which the stream server will listen. +# The port on which the stream server will listen. If the port is set to "0", then +# CRI-O will allocate a random free port number. stream_port = "0" # Enable encrypted TLS transport of the stream server. @@ -94,6 +99,10 @@ default_runtime = "runc" # If true, the runtime will not use pivot_root, but instead use MS_MOVE. no_pivot = false +# decryption_keys_path is the path where the keys required for +# image decryption are stored. This option supports live configuration reload. +decryption_keys_path = "/etc/crio/keys/" + # Path to the conmon binary, used for monitoring the OCI runtime. # Will be searched for using $PATH if empty. conmon = "/usr/libexec/crio/conmon" @@ -107,17 +116,26 @@ conmon_env = [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", ] +# Additional environment variables to set for all the +# containers. These are overridden if set in the +# container image spec or in the container runtime configuration. +default_env = [ +] + # If true, SELinux will be used for pod separation on the host. selinux = false # Path to the seccomp.json profile which is used as the default seccomp profile # for the runtime. If not specified, then the internal default seccomp profile -# will be used. +# will be used. This option supports live configuration reload. seccomp_profile = "" # Used to change the name of the default AppArmor profile of CRI-O. The default -# profile name is "crio-default-" followed by the version string of CRI-O. -apparmor_profile = "crio-default-1.16.1" +# profile name is "crio-default". This profile only takes effect if the user +# does not specify a profile via the Kubernetes Pod's metadata annotation. If +# the profile is set to "unconfined", then this equals to disabling AppArmor. +# This option supports live configuration reload. +apparmor_profile = "crio-default" # Cgroup management implementation used for the runtime. cgroup_manager = "systemd" @@ -126,17 +144,15 @@ cgroup_manager = "systemd" # only the capabilities defined in the containers json file by the user/kube # will be added. default_capabilities = [ - "CHOWN", - "DAC_OVERRIDE", - "FSETID", - "FOWNER", - "NET_RAW", - "SETGID", - "SETUID", - "SETPCAP", - "NET_BIND_SERVICE", - "SYS_CHROOT", - "KILL", + "CHOWN", + "DAC_OVERRIDE", + "FSETID", + "FOWNER", + "SETGID", + "SETUID", + "SETPCAP", + "NET_BIND_SERVICE", + "KILL", ] # List of default sysctls. If it is empty or commented out, only the sysctls @@ -151,8 +167,10 @@ default_sysctls = [ additional_devices = [ ] -# Path to OCI hooks directories for automatically executed hooks. +# Path to OCI hooks directories for automatically executed hooks. If one of the +# directories does not exist, then CRI-O will automatically skip them. hooks_dir = [ + "/usr/share/containers/oci/hooks.d", ] # List of default mounts for each container. **Deprecated:** this option will @@ -200,9 +218,13 @@ bind_mount_prefix = "" read_only = false # Changes the verbosity of the logs based on the level it is set to. Options -# are fatal, panic, error, warn, info, and debug. This option supports live -# configuration reload. -log_level = "error" +# are fatal, panic, error, warn, info, debug and trace. This option supports +# live configuration reload. +log_level = "info" + +# Filter the log messages by the provided regular expression. +# This option supports live configuration reload. +log_filter = "" # The UID mappings for the user namespace of each container. A range is # specified in the form containerUID:HostUID:Size. Multiple ranges must be @@ -215,12 +237,23 @@ uid_mappings = "" gid_mappings = "" # The minimal amount of time in seconds to wait before issuing a timeout -# regarding the proper termination of the container. -ctr_stop_timeout = 0 +# regarding the proper termination of the container. The lowest possible +# value is 30s, whereas lower values are not considered by CRI-O. +ctr_stop_timeout = 30 -# ManageNetworkNSLifecycle determines whether we pin and remove network namespace -# and manage its lifecycle. -manage_network_ns_lifecycle = false +# **DEPRECATED** this option is being replaced by manage_ns_lifecycle, which is described below. +# manage_network_ns_lifecycle = false + +# manage_ns_lifecycle determines whether we pin and remove namespaces +# and manage their lifecycle +manage_ns_lifecycle = false + +# The directory where the state of the managed namespaces gets tracked. +# Only used when manage_ns_lifecycle is true. +namespaces_dir = "/var/run" + +# pinns_path is the path to find the pinns binary, which is needed to manage namespace lifecycle +pinns_path = "/usr/bin/pinns" # The "crio.runtime.runtimes" table defines a list of OCI compatible runtimes. # The runtime to use is picked based on the runtime_handler provided by the CRI. @@ -281,7 +314,7 @@ global_auth_file = "" # The image used to instantiate infra containers. # This option supports live configuration reload. -pause_image = "k8s.gcr.io/pause:3.1" +pause_image = "k8s.gcr.io/pause:3.2" # The path to a file containing credentials specific for pulling the pause_image from # above. The file is similar to that of /var/lib/kubelet/config.json @@ -324,6 +357,10 @@ registries = [ # CNI plugins. [crio.network] +# The default CNI network name to be selected. If not set or "", then +# CRI-O will pick-up the first one found in network_dir. +# cni_default_network = "" + # Path to the directory where CNI configuration files are located. network_dir = "/etc/cni/net.d/" diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio.conf.default b/deploy/iso/minikube-iso/package/crio-bin/crio.conf.default index e456ca42da..2696dc4a10 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio.conf.default +++ b/deploy/iso/minikube-iso/package/crio-bin/crio.conf.default @@ -35,8 +35,15 @@ # the kubelet. The log directory specified must be an absolute directory. log_dir = "/var/log/crio/pods" -# Location for CRI-O to lay down the version file -version_file = "/var/lib/crio/version" +# Location for CRI-O to lay down the temporary version file. +# It is used to check if crio wipe should wipe containers, which should +# always happen on a node reboot +version_file = "/var/run/crio/version" + +# Location for CRI-O to lay down the persistent version file. +# It is used to check if crio wipe should wipe images, which should +# only happen when CRI-O has been upgraded +version_file_persist = "/var/lib/crio/version" # The crio.api table contains settings for the kubelet/gRPC interface. [crio.api] @@ -44,13 +51,11 @@ version_file = "/var/lib/crio/version" # Path to AF_LOCAL socket on which CRI-O will listen. listen = "/var/run/crio/crio.sock" -# Host IP considered as the primary IP to use by CRI-O for things such as host network IP. -host_ip = "" - # IP address on which the stream server will listen. stream_address = "127.0.0.1" -# The port on which the stream server will listen. +# The port on which the stream server will listen. If the port is set to "0", then +# CRI-O will allocate a random free port number. stream_port = "0" # Enable encrypted TLS transport of the stream server. @@ -94,6 +99,10 @@ default_runtime = "runc" # If true, the runtime will not use pivot_root, but instead use MS_MOVE. no_pivot = false +# decryption_keys_path is the path where the keys required for +# image decryption are stored. This option supports live configuration reload. +decryption_keys_path = "/etc/crio/keys/" + # Path to the conmon binary, used for monitoring the OCI runtime. # Will be searched for using $PATH if empty. conmon = "" @@ -107,36 +116,43 @@ conmon_env = [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", ] +# Additional environment variables to set for all the +# containers. These are overridden if set in the +# container image spec or in the container runtime configuration. +default_env = [ +] + # If true, SELinux will be used for pod separation on the host. selinux = false # Path to the seccomp.json profile which is used as the default seccomp profile # for the runtime. If not specified, then the internal default seccomp profile -# will be used. +# will be used. This option supports live configuration reload. seccomp_profile = "" # Used to change the name of the default AppArmor profile of CRI-O. The default -# profile name is "crio-default-" followed by the version string of CRI-O. -apparmor_profile = "crio-default-1.16.1" +# profile name is "crio-default". This profile only takes effect if the user +# does not specify a profile via the Kubernetes Pod's metadata annotation. If +# the profile is set to "unconfined", then this equals to disabling AppArmor. +# This option supports live configuration reload. +apparmor_profile = "crio-default" # Cgroup management implementation used for the runtime. -cgroup_manager = "cgroupfs" +cgroup_manager = "systemd" # List of default capabilities for containers. If it is empty or commented out, # only the capabilities defined in the containers json file by the user/kube # will be added. default_capabilities = [ - "CHOWN", - "DAC_OVERRIDE", - "FSETID", - "FOWNER", - "NET_RAW", - "SETGID", - "SETUID", - "SETPCAP", - "NET_BIND_SERVICE", - "SYS_CHROOT", - "KILL", + "CHOWN", + "DAC_OVERRIDE", + "FSETID", + "FOWNER", + "SETGID", + "SETUID", + "SETPCAP", + "NET_BIND_SERVICE", + "KILL", ] # List of default sysctls. If it is empty or commented out, only the sysctls @@ -151,8 +167,10 @@ default_sysctls = [ additional_devices = [ ] -# Path to OCI hooks directories for automatically executed hooks. +# Path to OCI hooks directories for automatically executed hooks. If one of the +# directories does not exist, then CRI-O will automatically skip them. hooks_dir = [ + "/usr/share/containers/oci/hooks.d", ] # List of default mounts for each container. **Deprecated:** this option will @@ -200,9 +218,13 @@ bind_mount_prefix = "" read_only = false # Changes the verbosity of the logs based on the level it is set to. Options -# are fatal, panic, error, warn, info, and debug. This option supports live -# configuration reload. -log_level = "error" +# are fatal, panic, error, warn, info, debug and trace. This option supports +# live configuration reload. +log_level = "info" + +# Filter the log messages by the provided regular expression. +# This option supports live configuration reload. +log_filter = "" # The UID mappings for the user namespace of each container. A range is # specified in the form containerUID:HostUID:Size. Multiple ranges must be @@ -215,12 +237,23 @@ uid_mappings = "" gid_mappings = "" # The minimal amount of time in seconds to wait before issuing a timeout -# regarding the proper termination of the container. -ctr_stop_timeout = 0 +# regarding the proper termination of the container. The lowest possible +# value is 30s, whereas lower values are not considered by CRI-O. +ctr_stop_timeout = 30 -# ManageNetworkNSLifecycle determines whether we pin and remove network namespace -# and manage its lifecycle. -manage_network_ns_lifecycle = false +# **DEPRECATED** this option is being replaced by manage_ns_lifecycle, which is described below. +# manage_network_ns_lifecycle = false + +# manage_ns_lifecycle determines whether we pin and remove namespaces +# and manage their lifecycle +manage_ns_lifecycle = false + +# The directory where the state of the managed namespaces gets tracked. +# Only used when manage_ns_lifecycle is true. +namespaces_dir = "/var/run" + +# pinns_path is the path to find the pinns binary, which is needed to manage namespace lifecycle +pinns_path = "" # The "crio.runtime.runtimes" table defines a list of OCI compatible runtimes. # The runtime to use is picked based on the runtime_handler provided by the CRI. @@ -281,7 +314,7 @@ global_auth_file = "" # The image used to instantiate infra containers. # This option supports live configuration reload. -pause_image = "k8s.gcr.io/pause:3.1" +pause_image = "k8s.gcr.io/pause:3.2" # The path to a file containing credentials specific for pulling the pause_image from # above. The file is similar to that of /var/lib/kubelet/config.json @@ -323,6 +356,10 @@ image_volumes = "mkdir" # CNI plugins. [crio.network] +# The default CNI network name to be selected. If not set or "", then +# CRI-O will pick-up the first one found in network_dir. +# cni_default_network = "" + # Path to the directory where CNI configuration files are located. network_dir = "/etc/cni/net.d/" From 4f2b2e006f4b12271b82b7b66f2cf00aba4c4281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 7 Jun 2020 19:29:06 +0200 Subject: [PATCH 05/13] Upgrade conmon to 2.0.17 This is used by both crio and podman, one bin for each But we try to use the same version, unless we have to... --- deploy/iso/minikube-iso/package/conmon/conmon.hash | 2 ++ deploy/iso/minikube-iso/package/conmon/conmon.mk | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/deploy/iso/minikube-iso/package/conmon/conmon.hash b/deploy/iso/minikube-iso/package/conmon/conmon.hash index 3c12036e1f..2180c0d189 100644 --- a/deploy/iso/minikube-iso/package/conmon/conmon.hash +++ b/deploy/iso/minikube-iso/package/conmon/conmon.hash @@ -6,3 +6,5 @@ sha256 6c9bf278ae6e125a39f1ae419e5bd314162a743f6587d70b1b6be095ac32b9af eb5fa88c sha256 50cc36636c32a343f4c9f5ab6b9f7f5edd5d6ef7c9c403793f799f6605597718 v2.0.3.tar.gz sha256 93f7c127cb536fc60f4c08291fd34e99e492fdc6a36e6b0ddad97d868ecf10f7 29c336700f2999acf9db07662b4a61355076e64a.tar.gz sha256 d82ad6c1e315f8310ed75fe6905f81dce61b61d55a156e9e04c9855e78e1e165 v2.0.6.tar.gz +sha256 abe4e1cc02505c81857c1eeced008a24b4dd41659d42a1e3395754fb063aef36 v2.0.7.tar.gz +sha256 a116b8422c65778bd677c29f55b3ceaae07d09da336f71bdc68fc7bb83d50e03 v2.0.17.tar.gz diff --git a/deploy/iso/minikube-iso/package/conmon/conmon.mk b/deploy/iso/minikube-iso/package/conmon/conmon.mk index ef077fa9b4..b38e4802f8 100644 --- a/deploy/iso/minikube-iso/package/conmon/conmon.mk +++ b/deploy/iso/minikube-iso/package/conmon/conmon.mk @@ -4,8 +4,8 @@ # ################################################################################ -CONMON_VERSION = v2.0.6 -CONMON_COMMIT = 29c336700f2999acf9db07662b4a61355076e64a +CONMON_VERSION = v2.0.17 +CONMON_COMMIT = 41877362fc4685d55e0473d2e4a1cbe5e1debee0 CONMON_SITE = https://github.com/containers/conmon/archive CONMON_SOURCE = $(CONMON_VERSION).tar.gz CONMON_LICENSE = Apache-2.0 From 6e619bd5c7653e01c908db88513d3abb0cedeb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 7 Jun 2020 19:40:18 +0200 Subject: [PATCH 06/13] The name of the make variable was changed Unfortunately there is no naming standard whatsoever, for these magic make variables for the git commit... --- deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk index 231ae37866..23fce96cc3 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk +++ b/deploy/iso/minikube-iso/package/crio-bin/crio-bin.mk @@ -32,7 +32,7 @@ endef define CRIO_BIN_BUILD_CMDS mkdir -p $(@D)/bin - $(CRIO_BIN_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) GIT_COMMIT=$(CRIO_BIN_COMMIT) PREFIX=/usr binaries + $(CRIO_BIN_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) COMMIT_NO=$(CRIO_BIN_COMMIT) PREFIX=/usr binaries endef define CRIO_BIN_INSTALL_TARGET_CMDS From 99d75c6b5b75d7a85689f2050a917f4d55945420 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Jun 2020 10:53:47 -0700 Subject: [PATCH 07/13] WIP --- pkg/minikube/image/image.go | 13 +++---------- pkg/minikube/node/cache.go | 2 ++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index ea50384699..cf5cfdde9a 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -34,7 +34,6 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "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/pkg/errors" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/localpath" @@ -101,15 +100,9 @@ func LoadFromTarball(img string) error { p := filepath.Join(constants.ImageCacheDir, img) p = localpath.SanitizeCacheDir(p) - tag, err := name.NewTag(img) - if err != nil { - return errors.Wrap(err, "tag") - } - - i, err := tarball.ImageFromPath(p, &tag) - _, err = daemon.Write(tag, i) - if err != nil { - return errors.Wrap(err, "writing daemon image") + cmd := exec.Command("docker", "load", "-i", p) + if output, err := cmd.CombinedOutput(); err != nil { + return errors.Wrapf(err, "%s", string(output)) } return nil } diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 0760209442..e8c97edf95 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -130,6 +130,8 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down glog.Infof("successfully loaded %s from cached tarball", img) finalImg = img return nil + } else { + fmt.Println("Failed to load tarball:", err) } glog.Infof("Downloading %s to local daemon", img) err := image.WriteImageToDaemon(img) From f36dd3083b52c48cfae106b9a293bf6ab1609667 Mon Sep 17 00:00:00 2001 From: Prasad Katti Date: Mon, 8 Jun 2020 11:43:29 -0700 Subject: [PATCH 08/13] Add link to the Kanban view to community page --- site/config.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/site/config.toml b/site/config.toml index 28a6603895..7a9c6cf087 100644 --- a/site/config.toml +++ b/site/config.toml @@ -159,6 +159,11 @@ no = 'Sorry to hear that. Please Date: Mon, 8 Jun 2020 14:01:06 -0700 Subject: [PATCH 09/13] Use go-containerregistry library instead of docker CLI --- pkg/minikube/image/image.go | 16 ++++++++++++---- pkg/minikube/node/cache.go | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index cf5cfdde9a..8321886eda 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -34,6 +34,7 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "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/pkg/errors" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/localpath" @@ -100,11 +101,18 @@ func LoadFromTarball(img string) error { p := filepath.Join(constants.ImageCacheDir, img) p = localpath.SanitizeCacheDir(p) - cmd := exec.Command("docker", "load", "-i", p) - if output, err := cmd.CombinedOutput(); err != nil { - return errors.Wrapf(err, "%s", string(output)) + tag, err := name.NewTag(Tag(img)) + if err != nil { + return errors.Wrap(err, "new tag") } - return nil + + i, err := tarball.ImageFromPath(p, &tag) + if err != nil { + return errors.Wrap(err, "tarball") + } + + _, err = daemon.Write(tag, i) + return err } // Tag returns just the image with the tag diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index e8c97edf95..67e2be7817 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -128,10 +128,10 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down for _, img := range append([]string{cc.KicBaseImage}, kic.FallbackImages...) { if err := image.LoadFromTarball(img); err == nil { glog.Infof("successfully loaded %s from cached tarball", img) - finalImg = img + // strip the digest from the img before saving it in the config + // because loading an image from tarball to daemon doesn't load the digest + finalImg = image.Tag(img) return nil - } else { - fmt.Println("Failed to load tarball:", err) } glog.Infof("Downloading %s to local daemon", img) err := image.WriteImageToDaemon(img) From 94da5201a62f90cc1dd3c77c3cbdba1e6f63a10f Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 8 Jun 2020 14:10:11 -0700 Subject: [PATCH 10/13] Add TODO --- pkg/minikube/image/image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index 8321886eda..2a42373e18 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -97,6 +97,7 @@ func ExistsImageInDaemon(img string) bool { } // LoadFromTarball checks if the image exists as a tarball and tries to load it to the local daemon +// TODO: Pass in if we are loading to docker or podman so this function can also be used for podman func LoadFromTarball(img string) error { p := filepath.Join(constants.ImageCacheDir, img) p = localpath.SanitizeCacheDir(p) From 325db092c335d76178181655d9a2fca94bc229b8 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Wed, 27 May 2020 18:57:45 +1000 Subject: [PATCH 11/13] Added option --all to stop all clusters Related to #8237 Signed-off-by: kadern0 --- cmd/minikube/cmd/stop.go | 63 ++++++++++++++++++++------- site/content/en/docs/commands/stop.md | 1 + 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index bd406e0036..c2a1a2d0ce 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -24,15 +24,20 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" + "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/mustload" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/util/retry" ) +var stopAll bool + // stopCmd represents the stop command var stopCmd = &cobra.Command{ Use: "stop", @@ -42,28 +47,54 @@ itself, leaving all files intact. The cluster can be started again with the "sta Run: runStop, } +func init() { + + stopCmd.Flags().BoolVar(&stopAll, "all", false, "Set flag to stop all profiles (clusters)") + + if err := viper.GetViper().BindPFlags(stopCmd.Flags()); err != nil { + exit.WithError("unable to bind flags", err) + } + + RootCmd.AddCommand(stopCmd) +} + // runStop handles the executes the flow of "minikube stop" func runStop(cmd *cobra.Command, args []string) { - cname := ClusterFlagValue() - - api, cc := mustload.Partial(cname) - defer api.Close() - - for _, n := range cc.Nodes { - machineName := driver.MachineName(*cc, n) - nonexistent := stop(api, machineName) - - if !nonexistent { - out.T(out.Stopped, `Node "{{.node_name}}" stopped.`, out.V{"node_name": machineName}) + // new code + var profilesToStop []string + if stopAll { + validProfiles, _, err := config.ListProfiles() + if err != nil { + glog.Warningf("'error loading profiles in minikube home %q: %v", localpath.MiniPath(), err) } + for _, profile := range validProfiles { + profilesToStop = append(profilesToStop, profile.Name) + } + } else { + cname := ClusterFlagValue() + profilesToStop = append(profilesToStop, cname) } + for _, profile := range profilesToStop { + // end new code + api, cc := mustload.Partial(profile) + defer api.Close() - if err := killMountProcess(); err != nil { - out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err}) - } + for _, n := range cc.Nodes { + machineName := driver.MachineName(*cc, n) + nonexistent := stop(api, machineName) - if err := kubeconfig.UnsetCurrentContext(cname, kubeconfig.PathFromEnv()); err != nil { - exit.WithError("update config", err) + if !nonexistent { + out.T(out.Stopped, `Node "{{.node_name}}" stopped.`, out.V{"node_name": machineName}) + } + } + + if err := killMountProcess(); err != nil { + out.WarningT("Unable to kill mount process: {{.error}}", out.V{"error": err}) + } + + if err := kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()); err != nil { + exit.WithError("update config", err) + } } } diff --git a/site/content/en/docs/commands/stop.md b/site/content/en/docs/commands/stop.md index 1966613930..442a735778 100644 --- a/site/content/en/docs/commands/stop.md +++ b/site/content/en/docs/commands/stop.md @@ -22,6 +22,7 @@ minikube stop [flags] ### Options ``` + --all Set flag to stop all profiles (clusters) -h, --help help for stop ``` From e37da349fbfee6f1c390ba2cf5d8b7033b9ed9e1 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 9 Jun 2020 10:18:53 -0700 Subject: [PATCH 12/13] pass in driver to load from tarball --- pkg/minikube/image/image.go | 29 ++++++++++++++++++----------- pkg/minikube/node/cache.go | 3 ++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index 2a42373e18..486b01825a 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -37,6 +37,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/tarball" "github.com/pkg/errors" "k8s.io/minikube/pkg/minikube/constants" + "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/localpath" ) @@ -98,22 +99,28 @@ func ExistsImageInDaemon(img string) bool { // LoadFromTarball checks if the image exists as a tarball and tries to load it to the local daemon // TODO: Pass in if we are loading to docker or podman so this function can also be used for podman -func LoadFromTarball(img string) error { +func LoadFromTarball(binary, img string) error { p := filepath.Join(constants.ImageCacheDir, img) p = localpath.SanitizeCacheDir(p) - tag, err := name.NewTag(Tag(img)) - if err != nil { - return errors.Wrap(err, "new tag") + switch binary { + case driver.Podman: + return fmt.Errorf("not yet implemented, see issue #8426") + default: + tag, err := name.NewTag(Tag(img)) + if err != nil { + return errors.Wrap(err, "new tag") + } + + i, err := tarball.ImageFromPath(p, &tag) + if err != nil { + return errors.Wrap(err, "tarball") + } + + _, err = daemon.Write(tag, i) + return err } - i, err := tarball.ImageFromPath(p, &tag) - if err != nil { - return errors.Wrap(err, "tarball") - } - - _, err = daemon.Write(tag, i) - return err } // Tag returns just the image with the tag diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 67e2be7817..8f4142745a 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -31,6 +31,7 @@ import ( "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/download" + "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/image" "k8s.io/minikube/pkg/minikube/localpath" @@ -126,7 +127,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down } }() for _, img := range append([]string{cc.KicBaseImage}, kic.FallbackImages...) { - if err := image.LoadFromTarball(img); err == nil { + if err := image.LoadFromTarball(driver.Docker, img); err == nil { glog.Infof("successfully loaded %s from cached tarball", img) // strip the digest from the img before saving it in the config // because loading an image from tarball to daemon doesn't load the digest From 11096160fe2f8f3514641b2254ae78d1dc809e3d Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 9 Jun 2020 10:25:18 -0700 Subject: [PATCH 13/13] improve warning message so it fits on one line --- pkg/minikube/node/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 8f4142745a..7114086467 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -122,7 +122,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down // If we end up using a fallback image, notify the user defer func() { if finalImg != "" && finalImg != cc.KicBaseImage { - out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s\n minikube will use %s as a fallback image", image.Tag(cc.KicBaseImage), image.Tag(finalImg), image.Tag(finalImg))) + out.WarningT(fmt.Sprintf("minikube was unable to download %s, but successfully downloaded %s as a fallback image", image.Tag(cc.KicBaseImage), image.Tag(finalImg))) cc.KicBaseImage = finalImg } }()