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

Switch away from ctr to nerdctl (orthogonal to the provider discussion) #3445

Open
AkihiroSuda opened this issue Dec 5, 2023 · 2 comments
Open
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Comments

@AkihiroSuda
Copy link
Member

Note

This topic is orthogonal to the current on-going discussion about nerdctl provider:

What should be cleaned up or changed:

Switch away from ctr to nerdctl:

func (c *containerdImporter) Pull(image, platform string) error {
return c.containerCmder.Command(
"ctr", "--namespace=k8s.io", "content", "fetch", "--platform="+platform, image,
).SetStdout(io.Discard).SetStderr(io.Discard).Run()
}
func (c *containerdImporter) LoadCommand() exec.Cmd {
return c.containerCmder.Command(
// TODO: ideally we do not need this in the future. we have fixed at least one image
"ctr", "--namespace=k8s.io", "images", "import", "--all-platforms", "--no-unpack", "--digests", "-",
)
}
func (c *containerdImporter) ListImported() ([]string, error) {
return exec.OutputLines(c.containerCmder.Command("ctr", "--namespace=k8s.io", "images", "list", "-q"))
}

// LoadImageArchive loads image onto the node, where image is a Reader over an image archive
func LoadImageArchive(n nodes.Node, image io.Reader) error {
snapshotter, err := getSnapshotter(n)
if err != nil {
return err
}
cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", "--all-platforms", "--digests", "--snapshotter="+snapshotter, "-").SetStdin(image)
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "failed to load image")
}
return nil
}

// ReTagImage is used to tag an ImageID with a custom tag specified by imageName parameter
func ReTagImage(n nodes.Node, imageID, imageName string) error {
var out bytes.Buffer
return n.Command("ctr", "--namespace=k8s.io", "images", "tag", "--force", imageID, imageName).SetStdout(&out).Run()
}

Why is this needed:
Because ctr does not guarantee to keep compatibility:
https://github.com/containerd/containerd/blob/v1.7.10/RELEASES.md#ctr-tool

The ctr tool provides the ability to introspect and understand the containerd
API. It is not considered a primary offering of the project and is unsupported in
that sense. While we understand its value as a debug tool, it may be completely
refactored or have breaking changes in minor releases.

Targeting ctr for feature additions reflects a misunderstanding of the containerd
architecture. Feature addition should focus on the client Go API and additions to
ctr may or may not be accepted at the discretion of the maintainers.

We will do our best to not break compatibility in the tool in patch releases.

@AkihiroSuda AkihiroSuda added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 5, 2023
@aojea
Copy link
Contributor

aojea commented Dec 5, 2023

Is nerctl already available in the kind node images?

@BenTheElder
Copy link
Member

Because ctr does not guarantee to keep compatibility:

This is a good point, however we control which ctr version we're using and kind tries not to break compatibility so we'd need a while before we can switch, otherwise we introduce another breaking change to

We will do our best to not break compatibility in the tool in patch releases.

This also makes it much less risky in the short term?

Is nerctl already available in the kind node images?

No, it's a separate project and we're not building it yet. We'd probably have to start including nerdctl for N releases since ctr has not broken us yet.

Also, I know that other users are using ctr via docker exec $node so there's that to consider ... As much as we try to tell people otherwise they do depend on what is in the node, and we'll wind up increasing the image size again or breaking them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

No branches or pull requests

3 participants