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

Implement lifecycle CRD #1628

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open

Implement lifecycle CRD #1628

wants to merge 39 commits into from

Conversation

natalieparellano
Copy link
Contributor

@natalieparellano natalieparellano commented May 29, 2024

Implement lifecycle CRD (RFC PR)

I am still testing this out locally to make sure everything threads together, but it might be ready for some initial feedback on the direction.

Marking as ready in the interest of getting feedback.

Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
…r/cluster builder reconcilers

Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
RegistryClient: &registry.Client{},
KpackVersion: cmd.Identifer,
LifecycleProvider: lifecycleProvider,
KeychainFactory: keychainFactory,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated change, this seems no longer used

pkg/apis/build/v1alpha2/build_types.go Outdated Show resolved Hide resolved
@@ -34,7 +34,9 @@ type Builder struct {
type BuilderSpec struct {
Tag string `json:"tag,omitempty"`
Stack corev1.ObjectReference `json:"stack,omitempty"`
Store corev1.ObjectReference `json:"store,omitempty"`
// TODO: confirm, should `json:"lifecycle,...` actually be `json:"clusterlifecycle,...`?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think...no? Since that is not the case for stack?

Comment on lines 43 to 50
type ResolvedClusterLifecycle struct {
Id string `json:"id,omitempty"` // TODO: confirm, should this be LatestImage?
Version string `json:"version,omitempty"`

// Deprecated: Use `LifecycleAPIs` instead
API LifecycleAPI `json:"api,omitempty"`
APIs LifecycleAPIs `json:"apis,omitempty"`
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feedback on the structure of this struct would be appreciated

)

func (cl *ClusterLifecycle) SetDefaults(context.Context) {
// TODO: confirm, should we add something here?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this where we specify the image to use if the lifecycle CRD is not configured?

pkg/buildchange/lifecycle_change.go Outdated Show resolved Hide resolved
pkg/cnb/build_metadata.go Outdated Show resolved Hide resolved
@@ -1063,24 +1087,6 @@ func (i *layerIteratorTester) testNextLayer(name string, test func(index int)) {
*i++
}

func layerToRemoteBuildpack(bpLayer buildpackLayer, layer *fakeLayer, secretRef registry.SecretRef) K8sRemoteBuildpack {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was unused

pkg/reconciler/build/build.go Outdated Show resolved Hide resolved
@@ -173,6 +181,17 @@ func (c *Reconciler) reconcileBuilder(ctx context.Context, builder *buildapi.Bui
},
}, builder.NamespacedName())

c.Tracker.Track(reconciler.Key{
NamespacedName: types.NamespacedName{
Name: builder.Spec.Lifecycle.Name, // TODO: confirm this is what we want
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right? Is there a better name for "Name" ...like maybe "ImageName" or "ImageTag"?

@@ -224,6 +243,11 @@ func (c *Reconciler) reconcileBuilder(ctx context.Context, builder *buildapi.Bui
return buildapi.BuilderRecord{}, errors.Errorf("Error: clusterstack '%s' is not ready", clusterStack.Name)
}

clusterLifecycle, err := c.ClusterLifecycleLister.Get(builder.Spec.Lifecycle.Name) // TODO: confirm this is what we want
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same Q as above

@@ -0,0 +1,145 @@
package clusterlifecycle
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I basically just copied the reconciler for clusterstack

Signed-off-by: Natalie Arellano <[email protected]>
…e image digest

We don't have the lifecycle image digest when inspecting the build status

Signed-off-by: Natalie Arellano <[email protected]>
it will never be ready

Signed-off-by: Natalie Arellano <[email protected]>
Commit is not going to work because we can't get this information
from the lifecycle image labels,
it is only available after a build from the application image labels

Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
@natalieparellano
Copy link
Contributor Author

Small update: I was able to create a clusterlifecycle and observe a new build get triggered when the lifecycle version updated.

Still working on getting the e2e tests working locally (having credential issues) and there are a few outstanding TODOs that I can resolve on my own, but this is ready for some feedback! 🙏🏼

@@ -50,6 +45,10 @@ func (r *RemoteBuilderCreator) CreateBuilder(
if err != nil {
return buildapi.BuilderRecord{}, err
}
lifecycleImage, _, err := r.RegistryClient.Fetch(lifecycleKeychain, clusterLifecycle.Spec.Image) // TODO: should there be a "latest image" on the status?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That way we could at least know the exact digest that was used, even if we don't use it anywhere?

Signed-off-by: Natalie Arellano <[email protected]>
@natalieparellano natalieparellano changed the title WIP: Implement lifecycle CRD Implement lifecycle CRD Jun 18, 2024
@natalieparellano natalieparellano marked this pull request as ready for review June 18, 2024 15:20
@natalieparellano natalieparellano requested a review from a team as a code owner June 18, 2024 15:20
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.

1 participant