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

preload a docker image on the k3s node agents #141

Merged
merged 3 commits into from Mar 5, 2019

Conversation

juliens
Copy link
Contributor

@juliens juliens commented Mar 4, 2019

This PR adds preloading existing container images ( docker save format ) from /var/lib/rancher/k3s/agent/images

Fixes #92

@dduportal
Copy link
Contributor

Confirmed that this version is working for my use case in #92

@ibuildthecloud
Copy link
Contributor

Does this work with compressed archives too? Just curious.

@@ -122,5 +127,41 @@ func Run(ctx context.Context, cfg *config.Node) error {
}
}

imageDir := "/var/lib/rancher/k3s/agent/images"
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add a new struct field, cfg.Containerd.Images which is the path to the images and then setup the real path in pkg/agent/config/config.go run(...)

for _, fileInfo := range fileInfos {
if !fileInfo.IsDir() {
filePath := filepath.Join(imageDir, fileInfo.Name())
fileContent, err := ioutil.ReadFile(filePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to cause memory issues because you are reading the whole thing into memory (could be gigabytes). Can you just open the file and pass that to import?

@dduportal
Copy link
Contributor

Does this work with compressed archives too? Just curious.

Have not tried yet.

Also, I have a strange issue: when using this image only for worker nodes, coredns never starts.
On the (debug) server node, I see the manifest to be written, but then nothing happens.

Trying to work from latest v0.2.0-rc2 to provide a reproducible use case.

@ibuildthecloud
Copy link
Contributor

@dduportal Sorry v0.2.0-rc2 is not working. I deleted the tag because it completely fails to start. So master is basically broken. I'm trying to fix now. Also need better CI :/

@ibuildthecloud
Copy link
Contributor

Master is fixed and v0.2.0-rc3 is released which is stable again.

@juliens
Copy link
Contributor Author

juliens commented Mar 4, 2019

Does this work with compressed archives too? Just curious.

I think that the containerd.import doesn't handle compressed archives, so it needs to be a specific developpement.

@ibuildthecloud
Copy link
Contributor

ibuildthecloud commented Mar 4, 2019

@juliens That's fine. We can add support for compression later. I left just one more small comment, if you can address that I'll merge and do a build with this in it.

Co-Authored-By: juliens <julien.salleyron@gmail.com>
@ibuildthecloud ibuildthecloud merged commit 4f13bd6 into k3s-io:master Mar 5, 2019
@ibuildthecloud
Copy link
Contributor

@juliens This should be in v0.2.0-rc4 now if you could please validate the build that would be great!

@ldez
Copy link
Contributor

ldez commented Mar 5, 2019

We (the Traefik team: @juliens, @dduportal and me) will validate if the k3s-inator 😄 works well tomorrow morning (it's 2am for us).

@mmatur
Copy link

mmatur commented Mar 5, 2019

It works perfectly. Thanks ;) 👏

@dduportal
Copy link
Contributor

Confirmed here also: works like a charm (v0.2.0-rc4 with image preloading).
Thanks @ibuildthecloud for this tool, adn thanks @juliens for the contribution

@crdil
Copy link

crdil commented May 26, 2019

I have added images which I exported with docker save to /var/lib/rancher/k3s/agent/images and then restarted k3s. In my k8s deployment I've added the image name to -image: <name> , but k3s still tries to fetch the image from docker.io.

I get the following error.

"rpc error: code = Unknown desc = failed to resolve image \"docker.io/library...

This should work right?

@demikl
Copy link

demikl commented Dec 14, 2020

I have added images which I exported with docker save to /var/lib/rancher/k3s/agent/images and then restarted k3s. In my k8s deployment I've added the image name to -image: <name> , but k3s still tries to fetch the image from docker.io.

I get the following error.

"rpc error: code = Unknown desc = failed to resolve image \"docker.io/library...

This should work right?

Hi, I just used this feature today. It looks like an image tagged as myimage in docker would result, in the containerd embedded in k3s, as :

docker.io/library/myimage

This can be observed through this command:

$ sudo k3s crictl images
IMAGE                                      TAG                 IMAGE ID            SIZE
docker.io/library/myimage                  latest              652014e0a66b3       82MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allows to preload a docker image on the k3s node agents
7 participants