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

Declerative targeting of packages to clusters #3542

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

mortent
Copy link
Contributor

@mortent mortent commented Sep 8, 2022

This adds the RootSyncRollout controller that provides declarative cluster targeting of packages built upon the RootSyncDeployment controller.

}

type ClusterTargetSelector struct {
ClusterType ClusterType `json:"clusterType,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be a GVK or GK? We can see how it goes though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we could make this a GK/GVK. That will help with discovery for clusters that are represented as resources in the local cluster, but we still need logic to know how to work with those clusters, i.e. connecting to them. Also, there might be situations where we want to discover clusters through some other mean that listing resources, although we could argue that all APIs must reflect clusters as resources.

)

type PackageSelector struct {
Namespace string `json:"namespace,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we need to go cross-namespace on either packages or targets, and I agree that packages is less dangerous!

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 we need to allow for cross-namespace. I added this partly as a way to allow for restricting the controller to target a subset of packages, given that package revisions do not yet support labels.

}

if apierrors.IsNotFound(err) {
klog.Infof("Creating rootsyncset %s", rootSyncSetName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can express this as creating a set of "child objects", and then use applylib or similar. Should be less code and take care of pruning. Not a blocker though!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I did consider that approach, but in the end decided on the more standard controller approach.

}

newReconcile := time.Now().Add(30 * time.Second)
r.NextScheduledReconcile[req.NamespacedName] = newReconcile
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 need to cache this information? I've always seen it just returning RequeueAfter...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow. Are you saying there is a way to query the workqueue to check when the next reconcile is scheduled for? This solution is just temporary until we have support for watches on packagerevisions and I've figured out how to set up watches correctly with labelselectors. That is the next steps here.

@justinsb
Copy link
Contributor

justinsb commented Sep 8, 2022

A few questions / thoughts, but looks good. Merge and iterate :-)

@mortent
Copy link
Contributor Author

mortent commented Sep 9, 2022

I agree with the merge and iterate approach, but I think we should come up with an approach where all the "very alpha" controllers doesn't run by default for users trying out Porch. We had some users reporting issues due to our renaming of some of the CRDs in the latest release. We could disable them in the regular porch release and just ask users who want to try them out to build from source. Or even better, publish porch as a kpt package an allow users to opt-in to these controllers if they want to.

@johnbelamaric
Copy link
Contributor

I agree with the merge and iterate approach, but I think we should come up with an approach where all the "very alpha" controllers doesn't run by default for users trying out Porch. We had some users reporting issues due to our renaming of some of the CRDs in the latest release. We could disable them in the regular porch release and just ask users who want to try them out to build from source. Or even better, publish porch as a kpt package an allow users to opt-in to these controllers if they want to.

I also think controllers with GCP-specific functionality need to be separated from the rest of the controllers and optionally deployed. Preferably in a single controller-manager. Alternatively they can be part of KCC, especially if they depend on KCC CRDs.

@mortent mortent force-pushed the DeclarativeClusterTargeting branch 2 times, most recently from f589bd5 to 05ede1e Compare September 14, 2022 22:49
@mortent mortent force-pushed the DeclarativeClusterTargeting branch 2 times, most recently from 12c1dd7 to c4dfd89 Compare September 21, 2022 23:15
@mortent mortent force-pushed the DeclarativeClusterTargeting branch 3 times, most recently from c3debe8 to 17068fd Compare November 22, 2022 13:08
@mortent mortent force-pushed the DeclarativeClusterTargeting branch 2 times, most recently from 31ff51e to 0cd7023 Compare December 7, 2022 21:33
@mortent mortent changed the title [WIP] Declerative targeting of packages to clusters Declerative targeting of packages to clusters Dec 7, 2022
@mortent mortent marked this pull request as ready for review December 8, 2022 11:08
}

func (r *RootSyncRolloutReconciler) findRolloutsForPackageRevision(pkgRev client.Object) []reconcile.Request {
// There is not support for reverse lookup by label: https://github.com/kubernetes/kubernetes/issues/1348
Copy link
Contributor

Choose a reason for hiding this comment

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

I think controller-runtime has some ability to build our own indexes, but I agree this is a pain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there is support for building indexes based on fields in controller-runtime, but I couldn't find support for indexes on labels.

@mortent mortent merged commit fa0a9a5 into kptdev:main Dec 9, 2022
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.

None yet

3 participants