kubebuilder
kubebuilder copied to clipboard
Remove path webhook marker
trafficstars
What do you want to happen?
Kubebuilder works as expected when I initialize a project and generate webhooks with:
kubebuilder init
kubebuilder create api --group foogroup --version v1beta1 --kind FooKind
kubebuilder create webhook --group foogroup --version v1beta1 --kind FooKind --defaulting --programmatic-validation
My assumption is that generated code is intended to be modified including the webhook markers. This is not true regarding path marker. It MUST follow the pattern described in the documentation as the controller-runtime registers webhooks on certain paths.
The path marker modification leads to a cryptic error:
Internal error occurred: failed calling webhook \"validate-foo\": failed to call webhook: the server could not find the requested resource
Suggestions:
- remove the
pathmarker, but still generate validwebhook/manifests.yaml - or add a comment in autogenerated code with the explanation that if the webhook is registered via the following code the path MUST not be modified
return ctrl.NewWebhookManagedBy(mgr).
For(typ).
Complete()
Something like:
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// NOTE that path must follow the pattern described in kubebuilder documentation.
//+kubebuilder:webhook:path=/validate-foogroup-my-domain-v1beta1-fookind,mutating=false,failurePolicy=fail,sideEffects=None,groups=foogroup.my.domain,resources=fookinds,verbs=create;update,versions=v1beta1,name=vfookind.kb.io,admissionReviewVersions=v1
Extra Labels
No response