-
Notifications
You must be signed in to change notification settings - Fork 106
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
Copy labels and annotations from SubnamespaceAnchor to child namespace #149
Conversation
|
Welcome @mishamo! |
Hi @mishamo. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change! Can you please explain a bit about why you want this feature?
But this isn't the UX I'd like to support this feature. The anchor should be able to have labels and annotations on it (e.g. "created-by: some-tool") that are not copied to the child namespaces. This is how labels and annotations work elsewhere in K8s - for example, the labels on a Deployment are not copied to its pods; rather, the podspec in the Deployment includes the labels that should be created on the pod.
In addition, HNC recently added a new feature (not yet released) called managed labels (link) and this feature needs to integrate with that. For example, this change will not propagate the labels/annotations to the descendants of the subnamespace, which we should definitely do.
So here's how I think we need to change this feature:
- In the
SubnamespaceAnchor
CRD, add a new.spec.labels
and.spec.annotations
field, mirroring the ones inHierarchyConfiguration
. - In the
HierarchyConfiguration
reconciler, modify thesyncSubnamespaceParent
method to copy the labels and annotations from the anchor to theHierarchyConfiguration
. Replace anything that's there (e.g. don't attempt to add or merge). The rest of the reconciler will actually put the labels/annotations on the namespace and its descendants. - Modify the validators to prevent adding illegal labels or annotations, at least as much as the current validators do (e.g. here). This may require some refactoring to avoid duplicating code. It's also ok to do this in a followup PR but please file an issue to do so.
Thanks!
/hold
Hi. Thanks for your feedback. It all sounds quite reasonable. Will look at updating this. Regarding the use case for this feature, we would simply like to create child namespaces with labels and annotations. We can already do this by creating the namespace with a plain |
The other option is to create the NS resource, and then create the
HierarchyConfiguration resource inside it, setting both the parent and
labels/annotations simultaneously. It's still a two-step process, but at
least it doesn't have an imperative command as a part of it. But I'm happy
to make the changes to SubnamespaceAnchor as well if you feel it's
important.
…On Thu, Feb 24, 2022 at 11:13 AM mishamo ***@***.***> wrote:
Hi. Thanks for your feedback. It all sounds quite reasonable. Will look at
updating this.
Regarding the use case for this feature, we would simply like to create
child namespaces with labels and annotations. We can already do this by
creating the namespace with a plain Namespace resource, then using kubectl
hns set to set the parent. It feels like it would be much more elegant to
be able to apply a single resource in a declarative manner, that could
already contain the namespaces and annotations; in this case a
SubnamespaceAnchor.
—
Reply to this email directly, view it on GitHub
<#149 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE43PZGKITCDQKLJKL4AWZ3U4ZKKJANCNFSM5PG3LKAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, We've taken a look at the proposed implementation/UX and think there might be a slight mismatch in our usecase/goal vs the proposed approach. We're looking to provide a mechanism for creating labels and annotations on namespaces that are created as a direct result of creating a Does that make sense? Or would there be a preferred approach to achieve this? |
My main concern with allowing |
I think I'm ok to have anchors include managed labels/annotations, since the admin of the parent namespace can always override what's allowed (even if we don't have a great UX for that yet). I'm much less comfortable including unmanaged labels/annotations on the subnamespaces for the reason that @erikgb says. Can you give us a very concrete idea of why you need this feature? E.g.:
This should help us either find another way for you to solve your problem or give us more clarity on how to implement this feature. |
Hi. I've discussed this with my colleagues and we feel that you're right in terms of security. We are the admins of the cluster and we have ~100 tenants. We would like generate parent namespaces for each tenant (with their individual roles and rolebindings to propagate to their children). Following that, tenants would be able to create their own children by applying We would like tenants (and ourselves, when generating the parents) to be able to add managed labels and annotations in one step, by creating the We've made some changes here: https://github.com/mishamo/hierarchical-namespaces/tree/changes We have added a test to check for label propagation (which is very similar to the test in the hierarchyconfig/reconciler_test) here: https://github.com/mishamo/hierarchical-namespaces/blob/824376bcbdcd692af00e8a76134753c32bb2faeb/internal/anchor/reconciler_test.go#L136 The issue we're having is that when the labels in the anchor are updated for the parent namespace (foo), the reconcilers for the child namespace (bar) are not triggered, because nothing has changed in those namespaces. Thus the hierarchyconfig/reconciler only reconciles for foo, not bar. We could add logic to the anchor reconciler to update the hierachyconfiguration in the child, but that feels like crossing a responsibility boundary. We could also potentially delegate to reconcile children from parents (i.e. a direct call to We're scratching our heads a little as to the best approach. Any advice would be welcome. |
If you change a label in the Hierarchy Config, it should trigger a reconciliation of all descendants (e.g. here). Is this not working for you? |
Hmm, what exactly is the problem? E.g. imagine you have a namespace hierarchy like this:
Is the problem that you're changing the labels/annotations on the If that's the problem, the fix is pretty simple - just update the listening rules:
This means that whenever an anchor is changed, we'll re-reconcile both the namespace that the anchor is in, as well as the subnamespace represented by that anchor. |
Hi. Yes that sounds exactly like the issue. I'll take a look at your suggestion on Monday. Thanks. |
Great, let me know!
…On Sat, Mar 5, 2022 at 5:39 PM mishamo ***@***.***> wrote:
Hi. Yes that sounds exactly like the issue. I'll take a look at your
suggestion on Monday. Thanks.
—
Reply to this email directly, view it on GitHub
<#149 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE43PZEHHQXVGG2ZDEV53OLU6PPA3ANCNFSM5PG3LKAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
@adrianludwin How does this look to you? Is it likely that this would fit into the 1.0 release? |
Will review today, thanks!
…On Tue, Mar 15, 2022 at 10:24 AM mishamo ***@***.***> wrote:
@adrianludwin <https://github.com/adrianludwin> How does this look to
you? Is it likely that this would fit into the 1.0 release?
—
Reply to this email directly, view it on GitHub
<#149 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE43PZBQRO6HJKOJTY4STETVACMS3ANCNFSM5PG3LKAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, thanks for making these changes. Just a few minor revisions.
/ok-to-test
Also, can you please update the commit message to describe the change as well as how you've tested it (e.g. "Added integ tests and tested manually" is probably enough for this case). |
E.g. see this commit message: 48df984 |
lgtm after one last cleanup of the commit message. It currently looks like you've merged a bunch of commit messages together? If you could modify it to look more like 48df984 I'd appreciate that! |
Thanks for that! I've updated the commit message with a brief description of the feature and removed the multiple interim commit messages. |
/retest |
I'm not quite sure why these tests (go vet) are failing? The imports look OK to me and I can't reproduce this locally. |
@mishamo I think the pipeline runs the result of adding your commit on top of the |
Allows managed labels and annotations to be created in the subnamespaceanchor.spec. See documentation on managed labels and managed annotations. Tested: Added integration tests and tested manually
@adrianludwin what are the chances of this making it into the 1.0 cut? |
Let's get #160 in first, then we'll merge this. I think v1.0 will go out shortly after that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adrianludwin, mishamo 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 |
@adrianludwin I think we can remove this hold correct? |
Whoops, thanks! /hold cancel |
No description provided.