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

cmd/load: ability to load from oci layout #2626

Open
Dentrax opened this issue Feb 10, 2022 · 8 comments
Open

cmd/load: ability to load from oci layout #2626

Dentrax opened this issue Feb 10, 2022 · 8 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.

Comments

@Dentrax
Copy link

Dentrax commented Feb 10, 2022

What would you like to be added:

Currently, we can load images from tar files or directly a docker image as follows:

Available Commands:
  docker-image  Loads docker images from host into nodes
  image-archive Loads docker image from archive into nodes

We can also add an oci-layout command here to load an image directly from a folder. As a workaround, we have to do:

$ skopeo copy oci:<OCI_DIR> docker://<DOCKER_IMAGE>
# and then
$ kind load docker-image <DOCKER_IMAGE>

vs.

$ kind load oci-dir <OCI_DIR>

To export your image as an oci-layout, ko have a support for that, for example.

Why is this needed:

To support OCI image layout.

cc @developer-guy @imjasonh

@Dentrax Dentrax added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 10, 2022
@BenTheElder
Copy link
Member

Is there some source that can only produce OCI? ko also supports docker tarballs instead of OCI.

Note that loading is performed in containerd / ctr. kind only streams the tarball and makes some minor optimizations.

It is important that we minimize the dependencies in the kind source code for embedding e.g. in cluster-api, this would probably have to be done as a feature to ctr.

@BenTheElder BenTheElder added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Mar 23, 2022
@Dentrax
Copy link
Author

Dentrax commented Mar 31, 2022

Let me ping @estesp @crosbymichael.

Hey! If does it make sense, We'd like to move this issue as a new feature proposal into containerd/ctr. I'm not so familiar with ctr domain, so maybe you can help us point in the right direction.

@estesp
Copy link
Contributor

estesp commented Mar 31, 2022

ctr image import already supports OCIv1 format:

USAGE:
   ctr images import [command options] [flags] <in>

DESCRIPTION:
   Import images from a tar stream.
Implemented formats:
- oci.v1
- docker.v1.1
- docker.v1.2

Is that sufficient for what you are looking for or did I misunderstand what you want to add to ctr?

@Dentrax
Copy link
Author

Dentrax commented Mar 31, 2022

Oh, thanks! Missed that.

In this case, we can easily add a new oci-dir subcommand into kind by adding a new function in nodeutils.go

func LoadImageFromDir(n nodes.Node, imageDir string) error {
 ...
 cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", imageDir)
 ...
}

As it already describes in import.go.

UX would be:

$ kind load oci-dir <OCI_DIR>

We can get to it if does it make sense. :)

@BenTheElder
Copy link
Member

BenTheElder commented Mar 31, 2022

I don't think it will be quite as easy as you say, with image tarballs we are piping in a file not a directory. ctr does not have host filesystem access in this case.

The use case question remains:

Is there some source that can only produce OCI? ko also supports docker tarballs instead of OCI.

@imjasonh
Copy link
Contributor

Yeah, ko's probably a bad example, since it can produce tarballs, and even load directly into KinD all by itself.

I don't know of any tools off the top of my head that can only produce OCI layouts. One nice thing that would enable though is being able to load multiple images in one command, since an OCI layout directory can describe many images.

The typical use case for OCI layouts lately has been as the format for carrying multiple images into a cluster across an airgap. So you could crane pull a bunch of images into an OCI layout, put that on a floppy disk or whatever, load it onto your machine and kind load that. But even that example's a bit moot, since crane pull can also produce regular per-image tarballs, which should work basically the same way.

@BenTheElder
Copy link
Member

BenTheElder commented Mar 31, 2022

I don't know of any tools off the top of my head that can only produce OCI layouts. One nice thing that would enable though is being able to load multiple images in one command, since an OCI layout directory can describe many images.

This is also true of a docker archive tarball from docker save etc., kind leverages this if you kind load docker-image one two. It's marginally quicker as it deduplicates layers on the host side.

This was referenced May 12, 2022
@BenTheElder
Copy link
Member

AIUI OCI-layout is a directory structure, so it's pretty unclear how we'd plumb that through. Existing kind load is roughly implemented by piping to ctr images import. I suppose we could tar and untar it ourselves over a pipe but that seems to be a questionable win over just sticking to archive tarballs ...?

I need to look more at the layout format or seek advice :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

No branches or pull requests

4 participants