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

✨ Add Upsync controller #2214

Conversation

bipuladh
Copy link
Contributor

Signed-off-by: Bipul Adhikari [email protected]

Summary

Adds Upsync controller
Creates resources in the Upstream workspace for labelled resources.

@openshift-ci openshift-ci bot requested review from jmprusi and ncdc October 18, 2022 14:19
@bipuladh bipuladh added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 18, 2022
pkg/syncer/upsync/upsync_controller.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
@davidfestal
Copy link
Member

davidfestal commented Oct 20, 2022

@bipuladh if a PR was not yet in a reviewable state (which was the case of this PR in its initlal state if I understood correctly what you told me), then you can also created it as a DRAFT PR, which makes it even clearer for other team members.

@bipuladh bipuladh marked this pull request as draft October 21, 2022 06:39
pkg/syncer/syncer.go Outdated Show resolved Hide resolved
@ncdc ncdc added the area/transparent-multi-cluster Related to scheduling of workloads into pclusters. label Nov 17, 2022
@bipuladh bipuladh force-pushed the 1980-storage-upsync-controller-syncer branch from 6a4456e to ea4ec3d Compare November 22, 2022 08:49
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2022
@openshift-ci openshift-ci bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Nov 22, 2022
@bipuladh bipuladh changed the base branch from 1980-storage-upsync-controller-syncer to main November 22, 2022 08:50
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2022
@bipuladh bipuladh linked an issue Nov 22, 2022 that may be closed by this pull request
@bipuladh bipuladh force-pushed the 1980-storage-upsync-controller-syncer branch 2 times, most recently from 50e77f4 to c121343 Compare November 23, 2022 10:26
@davidfestal davidfestal marked this pull request as ready for review November 24, 2022 08:45
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 24, 2022
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2022
@bipuladh bipuladh force-pushed the 1980-storage-upsync-controller-syncer branch from c121343 to 9c282ec Compare November 24, 2022 10:39
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2022
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
pkg/syncer/upsync/upsync_process.go Outdated Show resolved Hide resolved
@bipuladh bipuladh force-pushed the 1980-storage-upsync-controller-syncer branch 2 times, most recently from b3fffbf to c873af2 Compare November 29, 2022 11:30
@bipuladh bipuladh changed the title ✨ WIP: Add Upsync controller ✨ Add Upsync controller Nov 29, 2022
@bipuladh bipuladh force-pushed the 1980-storage-upsync-controller-syncer branch 2 times, most recently from 1409cc7 to 1e0ceaa Compare January 10, 2023 11:26
resourceVersionDownstream := downstreamResource.GetResourceVersion()
markedForDeletionDownstream := downstreamResource.GetDeletionTimestamp() != nil

if upstreamObject == nil && !markedForDeletionDownstream {
Copy link
Member

Choose a reason for hiding this comment

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

downstreamObject would match upstreamObject

Copy link
Member

Choose a reason for hiding this comment

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

wdym ?

@davidfestal davidfestal force-pushed the 1980-storage-upsync-controller-syncer branch from 8fe94d0 to 80a228b Compare February 15, 2023 18:31
Signed-off-by: David Festal <[email protected]>
var namespaceGVR schema.GroupVersionResource = corev1.SchemeGroupVersion.WithResource("namespaces")

// NewUpSyncer returns a new controller which upsyncs, through the Usyncer virtual workspace, downstream resources
// which are part of the upsyncable resource types (fixed limited list for now), and provide
Copy link
Contributor

Choose a reason for hiding this comment

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

question: What are the upsyncable resource types?

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 upsyncable resources are limited to pods, endpoints and persistentvolumeclaims. Both experimentation and code support my understanding:

https://github.com/bipuladh/kcp/blob/6cf3293ff35c3558e032c0cd3e4a00724c00e9ec/pkg/syncer/syncer.go#L236-L245

Copy link
Member

Choose a reason for hiding this comment

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

That's right, for now only these 3 resources are upsynced, since they correspond to the use-cases forseeable short-term.
Mid-term / long-term, we should have followup work that would allow customizing this list at the KCP level (and possibly storing it to the Synctarget status), but this still needs further design and discussion, especially to keep security in mind.

We should probably open a dedicated issue for this, to track the first thoughts we had in the regard, and further discuss the details.

Copy link
Member

Choose a reason for hiding this comment

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

The upsync controller is agnostic which GVRs are upsynced. But we are very opinionated in the wiring into the syncer for the moment. Whether we open that up eventually in some way, we will see.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @davidfestal @sttts

We should probably open a dedicated issue for this, to track the first thoughts we had in the regard, and further discuss the details.

I can take care of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any thoughts on how we could address Crossplane use cases ? (this is a similar use case to the one demoed by @sttts at Kubecon NA 2022 for Kube-bind). In this use case, Crossplane is installed in the physical cluster and Crossplane claims CRDs are imported in the kcp workspace. Crossplane claims typically create connection secrets, which are created in the backend cluster. But to give access to the resources created by those claims, the developer need to have access to the connection secret. Therefore, the connection secret should be up synced to the workspace where the claim lives. I created a PoC for a controller that runs downstream and for each Crossplane connection secret finds the owner (the down-synced claim) and can add the UpsSync label to the connection secret. I was hoping to use this PR to now close the loop and be able to up sync the connection secret. But it looks like with the current restriction that will not be possible unless I create my own fork for the syncer.

Copy link
Member

Choose a reason for hiding this comment

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

I created the related issue here: https://github.com/kcp-dev/kcp/issues/2804

Let's discuss in this new issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks ! I will copy the Crossplane use case description there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for creating the issue @davidfestal you were faster than me 🙇🏻

@sttts
Copy link
Member

sttts commented Feb 16, 2023

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 16, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 16, 2023
@openshift-merge-robot openshift-merge-robot merged commit ed5fced into kcp-dev:main Feb 16, 2023
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. area/transparent-multi-cluster Related to scheduling of workloads into pclusters. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storage - Upsync controller (syncer)
9 participants