-
Notifications
You must be signed in to change notification settings - Fork 5k
Preload images into docker volume #6720
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
Merged
priyawadhwa
merged 33 commits into
kubernetes:master
from
priyawadhwa:preload-images-into-docker-volume
Mar 3, 2020
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d506aa1
Download preloaded images tarball with --download-only flag
bb11bc6
Create volume of preloaded images and mount it in
b8bc461
Rebased on master
335637f
Name tarball by k8s version name
055e4bb
Add run to docker command
0e88697
Delete container once it has finished executing
97ea1b0
Remove preloaded base image and add makefile rule to upload prelaoded…
19fa296
Compress with lz4
b0f685c
Move all preloading code into preload package
5ac8520
skip transferring binaries and transferring imagse if using preloaded…
55dd40e
Debugging
86df9ff
Rebased on master
c99bf76
Add checksum verification
cc1a6f1
Delete volume if it isn't extracted properly so future runs don't try…
328466f
Check if preloaded volume is attached before skipping binary transfer
97bf128
only use preloaded volumes for docker runtime
dee8852
Don't require authentication to get checksum
8409fc3
wait to finish downloading kic artifacts before starting machine
aefbf2c
Rebased on master
6b0e942
Rebased on master
333caff
Merge branch 'master' of https://github.com/kubernetes/minikube into …
697359b
Fixed lint
474561d
remove unused functions
095b4b4
small fixes
742b3e4
remove transfer binaries
d6e94c1
remove unused functions
481010d
added overlay2 to preloaded images tarball name
4996b14
check for preloaded images before loading again
05a46f6
remove unnecessary PreloadedVolume
26de146
Add integration test for docker download only
5961513
Include container runtime and tarball version in preloaded tarball name
3d291fd
Only add necessary directories to tarball
5d16281
use docker command line to check if image exists, since it is much fa…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"k8s.io/minikube/pkg/minikube/assets" | ||
"k8s.io/minikube/pkg/minikube/command" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
"k8s.io/minikube/pkg/minikube/preload" | ||
) | ||
|
||
// Driver represents a kic driver https://minikube.sigs.k8s.io/docs/reference/drivers/docker | ||
|
@@ -90,14 +91,23 @@ func (d *Driver) Create() error { | |
ContainerPort: constants.DockerDaemonPort, | ||
}, | ||
) | ||
err := oci.CreateContainerNode(params) | ||
if err != nil { | ||
if err := oci.CreateContainerNode(params); err != nil { | ||
return errors.Wrap(err, "create kic node") | ||
} | ||
|
||
if err := d.prepareSSH(); err != nil { | ||
return errors.Wrap(err, "prepare kic ssh") | ||
} | ||
|
||
t := time.Now() | ||
glog.Infof("Starting extracting preloaded images to volume") | ||
// Extract preloaded images to container | ||
if err := oci.ExtractTarballToVolume(preload.TarballFilepath(d.NodeConfig.KubernetesVersion), params.Name, BaseImage); err != nil { | ||
glog.Infof("Unable to extract preloaded tarball to volume: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional nit: Warnf or Errorf so it doesn't get hidden in the logs. |
||
} else { | ||
glog.Infof("Took %f seconds to extract preloaded images to volume", time.Since(t).Seconds()) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,19 @@ func allVolumesByLabel(ociBin string, label string) ([]string, error) { | |
return vols, err | ||
} | ||
|
||
// ExtractTarballToVolume runs a docker image imageName which extracts the tarball at tarballPath | ||
// to the volume named volumeName | ||
func ExtractTarballToVolume(tarballPath, volumeName, imageName string) error { | ||
if err := PointToHostDockerDaemon(); err != nil { | ||
return errors.Wrap(err, "point host docker-daemon") | ||
} | ||
cmd := exec.Command(Docker, "run", "--rm", "--entrypoint", "/usr/bin/tar", "-v", fmt.Sprintf("%s:/preloaded.tar:ro", tarballPath), "-v", fmt.Sprintf("%s:/extractDir", volumeName), imageName, "-I", "lz4", "-xvf", "/preloaded.tar", "-C", "/extractDir") | ||
if out, err := cmd.CombinedOutput(); err != nil { | ||
return errors.Wrapf(err, "output %s", string(out)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional nit:
|
||
} | ||
return nil | ||
} | ||
|
||
// createDockerVolume creates a docker volume to be attached to the container with correct labels and prefixes based on profile name | ||
// Caution ! if volume already exists does NOT return an error and will not apply the minikube labels on it. | ||
// TODO: this should be fixed as a part of https://github.com/kubernetes/minikube/issues/6530 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.