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

Base entrypoint image on distroless #3286

Merged
merged 1 commit into from
Sep 27, 2020

Conversation

imjasonh
Copy link
Member

Reopening #2562 which for some reason GitHub/Prow won't let me reopen πŸ€·β€β™‚οΈ

With ko gaining multi-arch support, this change is becoming a bit more relevant, since it makes every TaskRun require a cp binary in the base image, which makes it harder to support multi-arch support in Tekton.


The only reason it was based on busybox was to have access to cp,
which it used to copy its binary to /tekton/tools for use in later
steps.

Instead of relying on cp, this adds a "cp mode" to the entrypoint
binary itself. When invoked with the positional args cp <src> <dst>,
it copies src to dst using Go's os and io packages.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • [y] Includes tests (if functionality changed/added)
  • [n] Includes docs (if user facing)
  • [y] Commit messages follow commit message best practices
  • [y] Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Base entrypoint image on distroless/static:nonroot and give it a mode to copy itself to the destination, instead of relying on cp being present in the base image.

cc @mattmoor @afrittoli @vdemeester

The only reason it was based on busybox was to have access to `cp`,
which it used to copy its binary to /tekton/tools for use in later
steps.

Instead of relying on `cp`, this adds a "cp mode" to the entrypoint
binary itself. When invoked with the positional args `cp <src> <dst>`,
it copies src to dst using Go's os and io packages.
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 26, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 26, 2020
@mattmoor
Copy link
Member

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 26, 2020
@mattmoor
Copy link
Member

/lgtm

FWIW :D

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 26, 2020
@imjasonh imjasonh removed the kind/feature Categorizes issue or PR as related to a new feature. label Sep 26, 2020
@imjasonh
Copy link
Member Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 26, 2020
@dlorenc
Copy link
Contributor

dlorenc commented Sep 27, 2020

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlorenc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2020
@imjasonh
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot merged commit 9c37fea into tektoncd:master Sep 27, 2020
@vdemeester
Copy link
Member

With ko gaining multi-arch support, this change is becoming a bit more relevant, since it makes every TaskRun require a cp binary in the base image, which makes it harder to support multi-arch support in Tekton.

I am not sure I follow entirely this, before this change, we just need to ensure that entrypoint image is multi-arch (just like busybox is I think), right ? Now it's based on a non-os image so we don't really need to care about multi-arch because there is only binaries in there ?

This just bakes cp in entrypoint as an very lightweight alternative of cp. One thing though, is this be considered as a breaking change as we are removing a some debug (busybox) tooling from the entrypoint image ?

@imjasonh
Copy link
Member Author

I am not sure I follow entirely this, before this change, we just need to ensure that entrypoint image is multi-arch (just like busybox is I think), right ? Now it's based on a non-os image so we don't really need to care about multi-arch because there is only binaries in there ?

Yep, exactly. It was based on distroless/base:debug before as an optimal middle-ground between "as minimal as possible (distroless)" and "contains cp", but now that we're trying to also make it multi-arch, I think it makes sense to base it on distroless/static instead. And we can do that just by moving cp into the binary itself.

Basing on busybox would also be an option, since it's multi-arch, but that moves us a bit further from the "as minimal as possible" goal.

This just bakes cp in entrypoint as an very lightweight alternative of cp. One thing though, is this be considered as a breaking change as we are removing a some debug (busybox) tooling from the entrypoint image ?

I don't think we should consider it a breaking change. The "debug stuff" was only present in the entrypoint image when it runs as an initContainer to copy the entrypoint binary out to the shared volume. I'm not even sure how a user would come to depend on that behavior, but if they did they're definitely doing something weird. πŸ™ƒ

@vdemeester
Copy link
Member

Yep, exactly. It was based on distroless/base:debug before as an optimal middle-ground between "as minimal as possible (distroless)" and "contains cp", but now that we're trying to also make it multi-arch, I think it makes sense to base it on distroless/static instead. And we can do that just by moving cp into the binary itself.

Well, we are not copying cp into the binary itself, we are "coding" cp 😝.

Basing on busybox would also be an option, since it's multi-arch, but that moves us a bit further from the "as minimal as possible" goal.

Isn't distroless/base:debug using busybox ? (I thought so, maybe I am wrong – or maybe it's alpine based).

I don't think we should consider it a breaking change. The "debug stuff" was only present in the entrypoint image when it runs as an initContainer to copy the entrypoint binary out to the shared volume. I'm not even sure how a user would come to depend on that behavior, but if they did they're definitely doing something weird. upside_down_face

We do publish the entrypoint image, so any user could use it as its own, independently of what Tekton does with it. I do agree it would be weird to use it (instead of an alpine or busybox image), but still, some might πŸ˜…

@imjasonh
Copy link
Member Author

Well, we are not copying cp into the binary itself, we are "coding" cp 😝.

Right right. Copying it's functionality, is what I meant.

Isn't distroless/base:debug using busybox ? (I thought so, maybe I am wrong – or maybe it's alpine based).

I don't think so:
Screen Shot 2020-09-28 at 9 16 49 AM

(from https://viz.kontain.me)

We do publish the entrypoint image, so any user could use it as its own, independently of what Tekton does with it. I do agree it would be weird to use it (instead of an alpine or busybox image), but still, some might πŸ˜…

I think I still consider that far enough outside intended use that if it breaks anybody it's because they were doing something we don't expect to support. (Hyrum's Law, of course, aside).

@vdemeester
Copy link
Member

https:/GoogleContainerTools/distroless#base-operating-system Interesting, it seems to track debian πŸ™ƒ πŸ‘Ό

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants