-
Notifications
You must be signed in to change notification settings - Fork 425
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
✨ feat: Add resource field-scoped fields #878
Conversation
Welcome @TheSpiritXIII! |
Hi @TheSpiritXIII. 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. |
c28336c
to
51a9ac8
Compare
51a9ac8
to
41f7c86
Compare
41f7c86
to
f414cc5
Compare
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.
+1 for this one (not maintainer, but reviewed the code)
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bwplotka, TheSpiritXIII The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Not a maintainer here, but I do API reviews. In general it is recommended not to recycle structs between types unless they are closely related. For example, imagine sharing a struct for a reference type and then someone starts adding a new field to it. You are unaware of this change, but they have now added a new field to your API, not desirable. So the use case here, is to use this for closely aligned structs, but, I'm wondering how we promote people to only use this feature for that use case 🤔 I am curious, can you expand on the need for a cluster and namespaced version of the same CRD? Does the cluster scoped version apply everywhere in the cluster and the namespaced version apply only to specific namespaces? Is the idea that different actors can configure the cluster wide policy but namespaced versions override that? |
I work on Google Cloud Managed Service for Prometheus. It's similar to prometheus-operator but slightly more opinionated. When you want to capture metrics for pods, you can use either
Exactly.
The namespace-scoped version is the more restrictive one. There's no concept of overriding in my use-case. If you have both, you get duplicate metrics.
I totally agree! In my case, they are closely related. I have deeply nested configurations which use a common type (similar to core's I'd love to see more opinions on this. It's possible that this particular use-case is a one-off. :) Thanks! |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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-sigs/prow repository. |
This feature adds resource field-scoped fields.
Why?
While working on Google Managed Service for Prometheus, we identified a need to have namespaced and cluster-scoped versions of the same structs.
How
This solution adds a new marker on fields that appear conditionally depending on the top-level CRD scope.
For example, we may have a struct:
For a namespaced CRD, the
namespace
field will not be generated as part of the OpenAPI specification because the namespace field is marked as being cluster-scoped.The opposite is true as well. A field can be marked namespaced and will not be generated for cluster-scoped resources.
Defaults apply too. A CRD is considered namespaced by default, so cluster-scoped fields will not appear.
Implementation
The implementation is admittedly a bit hacky. A special property is inserted at schema parse-time, and later removed when processing the resource. I couldn't figure out a better way to do this. The comments in the code should describe why it was done this way.