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

Enable Hub to take over "unmanaged resources" in member cluster #360

Closed
tom-data opened this issue Apr 3, 2023 · 3 comments
Closed

Enable Hub to take over "unmanaged resources" in member cluster #360

tom-data opened this issue Apr 3, 2023 · 3 comments
Labels
feature feature work

Comments

@tom-data
Copy link
Collaborator

tom-data commented Apr 3, 2023

There is a use case where namespaces have been created and workloads have been deployed to a cluster. Then this cluster joins the multicluster. In this case, we need to create namespace, namespace scoped resources and CRPs in the Hub. However, when work object is pulled by the work controller in the member cluster, the owner reference check fails in the function isManifestManagedByWork(). We want the work controller to treat this case as Hub taking over previously "unmanaged resources". The work controller shall create appliedWork for this resource and updated CRP status as in the case of successful creation of a new resource (propagated down from Hub) in the member cluster..

@implodingduck
Copy link

I was messing around with a similar thing, where I had existing namespaces and tried to get them into the fleet,

Getting the appliedwork object on the member cluster has a uid which you can add to existing resources for the ownerReferences...

Sample appliedwork from kubectl get appliedwork hello-world -oyaml

apiVersion: multicluster.x-k8s.io/v1alpha1
kind: AppliedWork
metadata:
  creationTimestamp: "2023-07-20T15:39:16Z"
  generation: 1
  name: hello-world
  resourceVersion: "31516"
  uid: ########-####-####-####-1313c541705b

Then I updated my namespace with the following ownerReferences metadata add last-applied-configuration annotation:

apiVersion: v1
kind: Namespace
metadata:
  name: hello-world
  ownerReferences:
  - apiVersion: multicluster.x-k8s.io/v1alpha1
    blockOwnerDeletion: false
    kind: AppliedWork
    name: hello-world
    uid: ########-####-####-####-1313c541705b
  annotations:
    fleet.azure.com/last-applied-configuration: '{}'

After a minute or two I was getting proper values for things from the Fleet hub...

I hope that can help with your use case!

@ryanzhang-oss ryanzhang-oss added the feature feature work label Jul 28, 2023
@ryanzhang-oss
Copy link
Contributor

Thanks for the suggestion, this is on our road map.

@zhiying-lin
Copy link
Contributor

This feature has been done in our latest release v0.10.3. If the existing resource on the member has no owner reference, appliedWork will be owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature work
Projects
None yet
Development

No branches or pull requests

4 participants