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

RFC to create a lifecycle crd #1483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

RFC to create a lifecycle crd #1483

wants to merge 1 commit into from

Conversation

tomkennedy513
Copy link
Collaborator

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e1722c0) 67.17% compared to head (1cb07da) 67.17%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1483   +/-   ##
=======================================
  Coverage   67.17%   67.17%           
=======================================
  Files         134      134           
  Lines        8276     8276           
=======================================
  Hits         5559     5559           
  Misses       2264     2264           
  Partials      453      453           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

patched upstream, requires any user to build the kpack specific lifecycle image themselves if the kpack provided one
has not been bumped.

As we [move to deprecate windows](https://github.com/buildpacks-community/kpack/discussions/1366), there is an opportunity for us to utilize
Copy link
Contributor

Choose a reason for hiding this comment

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

We do ship "lifecycle images" for Windows, so in theory you could specify the Windows image if Windows support is desired.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if we kept windows support a user would need to create a ClusterLifecycle for windows and reference that one in their builder. We should have os status on the new lifecycle crd and validation when generating a builder. I can add something about that in the event that windows doesn't get deprecated before we do this

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to support multi-arch lifecycle images? I.e. if I have an Image Index with linux/amd64, linux/arm64, and windows/amd64 images, do I need to break them out into 3 separate ClusterLifecycles?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a good question. I suspect the simpler approach would be to keep them separate, but I could be wrong. Would appreciate other more knowledgeable folks weighing in here.

Comment on lines 43 to 44
One open question is whether we should follow the Clusterstack model and keep this resource strictly cluster scoped or
follow the ClusterBuildpack pattern and provide a namespaced scoped version of the CRD.
Copy link
Contributor

@natalieparellano natalieparellano Jan 17, 2024

Choose a reason for hiding this comment

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

What are the pros and cons here? I could imagine, con of providing additional namespaced scoped resource is increased complexity. Anything else here?

I'd vote to do whatever is simplest and add more stuff later if it is ever needed or requested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the pro would be that a user that wants to use a particular version of the lifecycle that doesn't have cluster access can create a namespaced builder with a namespaced lifecycle. They would still run into the fact that stacks are cluster scoped only. I am in favor of only creating a cluster level resource but I feel pretty strongly that we should call it ClusterLifecycle to keep the door open for a namespaced one and to follow the naming convention of our other resources

The existing lifecycle reconciler can be updated to reconcile this new CRD instead of ConfigMaps.

A new field will be added to the ClusterBuilder/Builder resources allowing the user to provide a reference to a lifecycle CR.
This field will be optional and will default to the highest semantic version that is supported by the buildpacks in the builder and the platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that basically like how we hard-code the lifecycle version here?

lifecycleVersion = "0.17.2"

Would the future world deprecate that part of the code entirely? Like, if no ClusterLifecycle is specified do you get a default ClusterLifecycle or do you fallback to pulling the layer out of the lifecycleImage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ya this would get deprecated and we would pull in an upstream lifecycle in the ci pipeline instead of building our own like this file is doing.

we would still ship a default ClusterLifecycle to ease burden on our users and avoid a breaking change on upgrade

@tomkennedy513 tomkennedy513 marked this pull request as ready for review April 18, 2024 17:35
@tomkennedy513 tomkennedy513 requested a review from a team as a code owner April 18, 2024 17:35
@sambhav
Copy link
Contributor

sambhav commented Apr 18, 2024

A few unresolved qs from my side -

What happens when there are multiple lifecycle crds? Can we specify a default? Is this a cluster only resource? What happens when the lifecycle gets updated? Will we do a rebuild/rebase?

@natalieparellano
Copy link
Contributor

What happens when there are multiple lifecycle crds? Can we specify a default?

I think @tomkennedy513 was suggesting we use a webhook for that

Is this a cluster only resource?

Yes (this is detailed here)

What happens when the lifecycle gets updated? Will we do a rebuild/rebase?

Good question. For rebuild, I think yes? This is philosophically the same as updating your builder which already triggers a rebuild. For rebase, I think no? There would be no benefit if the run image didn't change. @tomkennedy513 @chenbh could you confirm my understanding?

For rebase, I think no?

BUT we may want to explore (on the CNB-spec side) "launcher layer rebase" to update the go version in the launcher which (when outdated) can cause pain.

@natalieparellano
Copy link
Contributor

@tomkennedy513 @chenbh I'd like to work on this. Is there an issue for it? Could we create one (pending the approval of this RFC)?

@tomkennedy513
Copy link
Collaborator Author

What happens when there are multiple lifecycle crds? Can we specify a default?

I think @tomkennedy513 was suggesting we use a webhook for that

I was thinking we may go down the same path we did with clusterstack where the kp cli will use a lifecycle crd called default (and we will ship with one called default). Alternatively we were thinking that the kpack webhook could do the exact same thing where it looks for one called default.

Is this a cluster only resource?

Yes (this is detailed here)

What happens when the lifecycle gets updated? Will we do a rebuild/rebase?

Good question. For rebuild, I think yes? This is philosophically the same as updating your builder which already triggers a rebuild. For rebase, I think no? There would be no benefit if the run image didn't change. @tomkennedy513 @chenbh could you confirm my understanding?

For rebase, I think no?

BUT we may want to explore (on the CNB-spec side) "launcher layer rebase" to update the go version in the launcher which (when outdated) can cause pain.

It would cause a rebuild because the builder would be rewritten. You can mimic this today by updating the lifecycle in the configmap

@tomkennedy513
Copy link
Collaborator Author

@tomkennedy513 @chenbh I'd like to work on this. Is there an issue for it? Could we create one (pending the approval of this RFC)?

I dont think we have one, are you ok making one

@natalieparellano
Copy link
Contributor

Made an issue to track the work on this: #1609

The existing lifecycle reconciler can be updated to reconcile this new CRD instead of ConfigMaps.

A new field will be added to the ClusterBuilder/Builder resources allowing the user to provide a reference to a lifecycle CR.
This field will be optional and will default to the highest semantic version that is supported by the buildpacks in the builder and the platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This field will be optional and will default to the highest semantic version that is supported by the buildpacks in the builder and the platform.
This field will be optional and will default to the highest semantic version that is supported by the platform.

Buildpacks are configured by the operator, so I don't think we can know which Buildpack APIs will be required... right? In theory (assuming we think most buildpacks in the wild have upgraded to at least Buildpack API 0.7 - since lifecycle 0.18.x and higher drops support for earlier APIs) it should be the highest semantic version that supports the Platform APIs here...right? In practice, that is going to mean the latest available lifecycle (until we deprecate more Platform APIs).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we do validate that any buildpack referenced in the order is using buildpack apis supported by the lifecycle when constructing a builder

func (bb *builderBlder) validateBuilder(sortedBuildpacks []DescriptiveBuildpackInfo) error {
platformApis := append(bb.LifecycleMetadata.APIs.Platform.Deprecated, bb.LifecycleMetadata.APIs.Platform.Supported...)
err := validatePlatformApis(platformApis)
if err != nil {
return err
}
buildpackApis := append(bb.LifecycleMetadata.APIs.Buildpack.Deprecated, bb.LifecycleMetadata.APIs.Buildpack.Supported...)
for _, bpInfo := range sortedBuildpacks {
bpLayerInfo := bb.buildpackLayers[bpInfo].BuildpackLayerInfo
err := bpLayerInfo.supports(buildpackApis, bb.stackId, bb.mixins, relaxedMixinContract(platformApis))
if err != nil {
return errors.Wrapf(err, "validating buildpack %s", bpInfo)
}
}
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see - but that validation happens after the ClusterLifecycle is defined, no? So in the case that the provided lifecycle doesn't support a buildpack in the builder we just fail, right? (Instead of selecting a different lifecycle?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the only check we'd want when the cluster lifecycle is reconciled is the platform api compatibility. The buildpack api compatibility will continue to happen at builder creation

@natalieparellano
Copy link
Contributor

FYI the PR implementing the changes proposed here is ready for feedback: #1628

So, we should probably circle back to this RFC to see if it is acceptable as-is or if it needs changes.

cc @tomkennedy513 @chenbh @samj1912

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.

5 participants