-
Notifications
You must be signed in to change notification settings - Fork 447
✨ Add feature gate marker support #1259
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wazery 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 |
Welcome @wazery! |
Hi @wazery. 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-sigs/prow 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.
I'm keen to seen progress on this issue, thanks @wazery for starting the push forward.
Feature gating is complex when it comes to CRDs. I'd be keen to see if we can also work out a plan for how we will gate specific markers, is that something we can align on as a project before we move forward?
Specifically I've seen needs for feature gated different enum sets, different feature gated XValidations and different values for things like Min/Max items that are feature gated.
But perhaps we actually need to be able to support gating all of the various markers we support?
/ok-to-test
3001605
to
b15c521
Compare
b15c521
to
de2450b
Compare
Thanks a lot Joel for your review, I truly appreciate it and learn much from it. As you can see in the current implementation it's very initial, and allows only binary field inclusion so either the entire field is in or out. Yet we can enhance the implementation further to address your cases:
For example: Option A: Inline Feature Gate Syntax
Option B: Dedicated Feature Gate Markers
Option C: Block-based Feature Gating
I love to hear your thoughts on how do you think we have to move forward on this PR, and truly appreciated your help 🙇. |
Based on feedback from PR kubernetes-sigs#1259 review comments, enhance RBAC feature gates with: - Support for complex feature gate expressions using OR (|) and AND (&) logic - Enhanced documentation with clear usage examples - Validation for feature gate expressions with proper error handling - Comprehensive test coverage for multiple gate scenarios New feature gate syntax: - Single gate: featureGate=alpha - OR logic: featureGate=alpha|beta (enabled if ANY gate is true) - AND logic: featureGate=alpha&beta (enabled if ALL gates are true) Examples: // +kubebuilder:rbac:featureGate=alpha|beta,groups=apps,resources=deployments,verbs=get;list // +kubebuilder:rbac:featureGate=alpha&beta,groups="",resources=services,verbs=get;list Addresses maintainer feedback on expression validation, multiple gate support, and improved documentation clarity.
Based on feedback from PR kubernetes-sigs#1259 review comments, enhance RBAC feature gates with: - Support for complex feature gate expressions using OR (|) and AND (&) logic - Enhanced documentation with clear usage examples - Validation for feature gate expressions with proper error handling - Comprehensive test coverage for multiple gate scenarios New feature gate syntax: - Single gate: featureGate=alpha - OR logic: featureGate=alpha|beta (enabled if ANY gate is true) - AND logic: featureGate=alpha&beta (enabled if ALL gates are true) Examples: // +kubebuilder:rbac:featureGate=alpha|beta,groups=apps,resources=deployments,verbs=get;list // +kubebuilder:rbac:featureGate=alpha&beta,groups="",resources=services,verbs=get;list Addresses maintainer feedback on expression validation, multiple gate support, and improved documentation clarity.
ff80782
to
cc41ffa
Compare
From your suggestions, I'd be interested to see if we can move towards Option A, though I don't know how simple that is for markers where we currently don't have keyed values. So for example, in XValidation, it's easy to add another value as it's already a multi-value marker. For the single value markers, adding an optional additional field isn't something I've looked into (not recently at least), but from the UX perspective sounds like the best IMO Interested to see if other maintainers have opinions on this project @alvaroaleman @sbueringer (and @everettraven who is a colleague who helps me with API review at RH) |
101f809
to
2e1498d
Compare
2e1498d
to
e53dccf
Compare
e53dccf
to
53df8d4
Compare
73f7c9b
to
e3a9853
Compare
0414f0a
to
98e49af
Compare
…ok generators - Add centralized featuregate package with evaluation and parsing logic - Implement CRD feature gate markers for conditional field inclusion - Add RBAC feature gate support with multiple gate evaluation - Extend Webhook generator with feature gate capabilities - Include comprehensive test coverage and golden output files
Add +kubebuilder:featuregate marker support for conditional CRD type generation with OR/AND expression support.
98e49af
to
48dcf3c
Compare
PR SummaryScope: This PR implements comprehensive feature gate support across all controller-tools generators: What's Supported:
What's NOT Supported (Future Work):While rewriting the PR to have a centralised utility for supporting feature gates, I found it would require modifying each validation marker definition and the schema generation logic - a significant undertaking that should be its own focused effort. IMHO we can do that in another follow up PR. Feature-gated validation markers:
Also in a follow up PR I can include the following features (a work in progress now)
These feature requests are mentioned in the issue #1238 Looking forward to your reviews 🙇 |
I'm currently working with the declarative validation folks and the API review folks upstream to work out what feature gating might look like in terms of markers there. I think we may want to copy their pattern downstream which is slightly more general, and uses chaining. For example, the The syntax and behaviour upstream is not quite cemented yet but I'm hoping that during the 1.35 cycle it will be, and that will allow us to start thinking about how this might work in the world of custom resources |
Implements
+kubebuilder:feature-gate=<gate-name>
marker that allows fields to be conditionally included in generated CRDs based on enabled feature gates.Addresses #1238, and #600