-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨ Webhooks for external APIs #4176
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fischor 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 @fischor! |
Hi @fischor. 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. |
) | ||
|
||
// nolint:unused | ||
// log is for logging in this package. | ||
var {{ lower .Resource.Kind }}log = logf.Log.WithName("{{ lower .Resource.Kind }}-resource") | ||
|
||
// SetupWebhookWithManager will setup the manager to manage the webhooks. | ||
{{- if .ExternalAPI }} | ||
func SetupWebhookFor{{ .Resource.Kind }}WithManager(mgr ctrl.Manager) error { |
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.
Those changes will not be required after : #4150
return ctrl.NewWebhookManagedBy(mgr). | ||
{{- if .ExternalAPI }} | ||
For(&{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}). |
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.
Here should be if the Resource.Path is not empty
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.
Thank you a lot for looking on that.
But the changes here will be a little diff.
Add the support for Core and External types is blocked by:
- ⚠️ (go/v4) decouple webhooks from APIs (Move Webhooks from
api/<version>
orapi/<group>/<version>
tointernal/webhook/<version>
orinternal/webhook/<group>/<version>
) #4150 - ✨ Add support to scaffold controllers for External Types #4171
After we get this merged then we can do that in more precisely way and add tests to ensure it.
Please
/hold
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.
Review Feedback:
Modular Flag Addition: The flag for external resources seems essential, but clarity is needed on whether it should be added globally or to the Golang plugin. Care should be taken to ensure backward compatibility.
Webhook Setup Changes: The SetupWebhookForJobWithManager function modification looks appropriate for external types, but detailed testing and validation are required to ensure seamless integration with external APIs.
Dependency on Other PRs: The PR (#4150) decoupling webhooks from APIs needs to be merged first, as the current PR's changes depend on it.
Next Steps:
Rebase on #4150 and #4171 once they are merged.
Add tests to validate external API support fully.
Collaborate on flag placement (global vs. plugin).
Hi @fischor, @sundaram2021, Thank you for looking into this. We do plan to add support for this feature. However, I would suggest not spending time on it right now, as the approach we'll take will be slightly different from how it's done in this context. It will likely be addressed as a follow-up to the ongoing PR: #4176 (review). I want to ensure that no time or effort is wasted, as there are many other priorities in the project! If you'd like to help us move forward, we'd really appreciate your assistance with reviewing this PR: #4150. This will help us reach our goal more efficiently. Thanks! 🎉 |
if p.force { | ||
return nil | ||
} |
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.
It is not the same of what was implemented before.
Hi @fischor I think the changes here would not work See that we should add the call to generate the webhook to test it out in https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/testdata/generate.sh |
@camilamacedo86 Yes, that is the plan. I am waiting for these two PRs to get merged before continuing. |
PR needs rebase. 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 is a WIP branch. But looking for feedback already.
With this PR scaffolding for core resource types will be added. Addresses #2141.
This will currently only work with core resources, not external resources per se, since a flag to describe the external Go module is missing in this PR as of now.
Currently the changes in this PR rely of this map of groups here to get the external path set if its a core resource:
kubebuilder/pkg/plugins/golang/options.go
Line 118 in 662f78f
Adding a flag like
--module
orresource-pkg-path
would make this work with general external resources.This flag could be added as part of the Golang plugin flag set or as part of the global kubebuilder flag set.
I am unsure if adding this flag to the global kubebuilder flag set might break some plugins that never assumed they will ever have to deal with external plugins.
So adding this flag to the global kubebuilder flag set would need further discussion I think.
I also had to change the
SetupWithManager
method that is as of now a receiver method on the resource struct type since one can not define methods on external struct types in Go.At the moment it looks like this:
It seems webhooks are going to be moved to internal/webhook anyway: #4150
Then the new schema is similiar.
A
--external-api-path
flag is added also in #4171 as part of the Golang plugin flag set.Feedback welcome.
I would espacially need to know:
api/<version>
orapi/<group>/<version>
tointernal/webhook/<version>
orinternal/webhook/<group>/<version>
) #4150 (probably yes)?