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

Don't cache images when --vmdriver=none #4059

Merged
Changes from 3 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
18 changes: 17 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func init() {
startCmd.Flags().String(networkPlugin, "", "The name of the network plugin")
startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\"")
startCmd.Flags().String(featureGates, "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine.")
startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --vm-driver=none.")
startCmd.Flags().Var(&extraOptions, "extra-config",
`A set of key=value pairs that describe configuration that may be passed to different components.
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
Expand Down Expand Up @@ -174,6 +174,22 @@ func runStart(cmd *cobra.Command, args []string) {
exit.WithError("Failed to generate config", err)
}

if viper.GetString(vmDriver) == constants.DriverNone {
/*
Caching images means:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do with a much smaller comment:

// Optimization: images will be persistently loaded into host Docker, so no need to duplicate work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to be policitally correct it should be "the container runtime", not Docker®

- minikube download the images
- minikube saves them in ~/.minikube/cache
- minikube loads them to the host machine with `docker load -i ~/.minikube/cache/some_images`

This makes complete sense, except that when --vm-driver=none, the host machine is the local machine.
That means once the images is loaded into docker, it stays there even after reboots and `minikube delete`.
That means they are already cached and nothing needs to be done. Not only that, loading the container with
`docker load -i ~/.minikube/cache/some_images` is unecessary and takes time.
As a bonus, we save disk space.
*/
viper.Set(cacheImages, false)
}

var cacheGroup errgroup.Group
beginCacheImages(&cacheGroup, k8sVersion)

Expand Down