-
Notifications
You must be signed in to change notification settings - Fork 113
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
WIP: Rebase BuildStrategy #656
Comments
Good topic, Jason! Actually, we also care about that because we run the Build on our official environment. And we care about the first case very much. My two cents:
---
apiVersion: shipwright.io/v1alpha1
kind: BuildRun
metadata:
name: buildpack-nodejs-buildrun
spec:
buildRef:
name: buildpack-nodejs-build
serviceAccount:
generate: true
rebase:
registry.access.redhat.com/ubi8-minimal
So when we were thinking about this requirement before, we just think of buildpacks first. But I think it is a good topic, we can think about that together :) |
Thanks for your response! I had imagined this being phrased as another type of parameterized BuildStrategy, but one that didn't require any source input, only an image to rebase. apiVersion: shipwright.io/v1alpha1
kind: Build
metadata:
name: rebase
spec:
inputs:
- name: image
type: Image
value: gcr.io/my/image
strategy:
name: rebase
params:
old_base: ubuntu
new_base: registry.access.redhat.com/ubi8-minimal (This assumes parameterized strategies and Adam's inputs EP land) Then you could run this any number of times as new The real reason I want this as a Build instead of a configuration of a BuildRun is that I want to be able to trigger these automatically when base images change. I think you're describing another feature where Builds (or Runs?) can immediately rewrite the base image of images they produce, sort of like how
Yeah, Dockerfile builds are less likely to be safe in every case, but if someone knows it's safe there's no reason to disallow it. Once the standard annotations are in, it shouldn't be hard to make Kaniko write those at least, so you won't need params in most cases. |
I'd like to be really careful not to expand the scope of this to include triggering. That's a separate EP entirely, which should be designed in isolation in such a way that rebuilds or rebases both work equally well. I'd like us to design that too, but separately from supporting rebasing. Rebasing will be supported as a one-time operation for now (just as one-time build runs are supported now), but which can be triggered in the future. I like to think of it as just another kind of It's possible a user would want to request a build from source, then as a followup operation, request a rebase of that resulting image on top of another image. That use case is supported today using |
Agree.
If it is supported as a one-time operation for now but can be triggered in the future, so it also related to trigger, so I think we should be careful and have a better design also for future feature integration, like trigger. I totally agree this is a valid scenario we should support. I am just thinking for this kind of requirement, if a new |
The reason a |
My two cents so far are:
|
I would agree with @qu1queee that while both the @imjasonh and @zhangtbj ideas introduced here share a common goal of helping to "trim images" or "make them leaner" as is cited in https://github.com/shipwright-io/build/blob/master/docs/proposals/runtime-image.md they in fact they do not overlap so much in the scenarios they are addressing. I'm also not 100% sure @imjasonh was suggesting that, but I think it helps to explicitly confirm that the commonality most likely stops at the shared goal. I'm possibly oversimplifying, but from what I've read, rebase seems to == replace layers, where as the https://github.com/shipwright-io/build/blob/master/docs/proposals/runtime-image.md == minimize the size of the layers you add on top of the existing layers I also think of https://github.com/shipwright-io/build/blob/master/docs/proposals/runtime-image.md as having some sub-goals of
But I'm of course curious as to what @sbose78 and @otaviof as the authors of the EP think, and if they share my recollections / inferences. https://github.com/shipwright-io/build/blob/master/docs/proposals/runtime-image.md also bleeds into what could be included in With all that ^^, I'm however not sure @imjasonh and/or @zhangtbj ideas here are a replacement for https://github.com/shipwright-io/build/blob/master/docs/proposals/runtime-image.md However, I think I could see some form of both proving complementary and useful to users. |
I am explicitly not interested in adding image-slimming functionality to the core Shipwright API; that's something that can already be expressed better in a Dockerfile or buildpacks, and those features and communities are far more established and moving faster, so we'll never catch up. I'd like to deprecate and phase out runtime-image, and I believe it should be relatively straightforward to do today since (we think) it has relatively little use.
Multi-stage docker builds do exist today though, and I think there's far more understanding and support for them now. I don't think this is a feature of OpenShift Builds we need to carry over to Shipwright.
Rebasing doesn't require
I'd like to deprecate and phase out |
Yep I'm OK with that. I was mostly trying to convey background and context. And in this particular case, explaining how to move from our old thing to the new thing should not be difficult. And I have not heard / cannot think of why a user would be inclined to express the desire to copy a subset of content from an image via k8s types and yaml instead of Dockerfile commands, or any analogous functionality across the spectrum of image building tools (present or future).
|
Yes, I think the alternative to the runtime feature is a user Dockerfile that follows the multi-stage best practices. @imjasonh for the rebase strategy and merely speaking about buildpacks, one needs to do a Or are you saying that in general for any |
Using
|
yes, thats my understanding. I still think we should also have a |
(This is a precursor to a full EP on the topic, to get ideas out and start discussion)
In a "rebase" operation, an original image's base image layers are swapped out with another set of layers from another image.
Users might want to do this for a couple reasons:
ubi
oropenjdk-slim
, etc.(the second case, producing slimmer built images, seems to be a motivating use case for
runtime
config)In either case, rebasing is not guaranteed to be safe by default, and care must be taken when building to ensure your application code can handle being rebased onto other base images. Rebasing onto a base image with different versions of system libraries or installed runtimes might produce an image that can't execute. Rebased images should still be subjected to tests before being deployed to production. Buildpacks for example takes care to separate application layers from base image layers, so that rebasing is more likely to be successful.
To enable rebasing in Shipwright, we could define a new
rebase
BuildStrategy, which would expect an input image, and parameters for old- and new-base images (or could expect this to be stored in OCI image annotations on the image), and anoutput
of where to publish the newly rebased image. (As an alternative, we could define a newRebase
CRD alongsideBuild
, since they're fairly separate operations, I'm not sure that's necessary though, and a BuildStrategy is easier to iterate on)When BuildRuns are triggered, rebasing builds could watch for updates to a base image and automatically produce rebased images built on that new base image.
References:
crane rebase
documentationcc @sbose78
The text was updated successfully, but these errors were encountered: