-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
docs: controllers and webhooks for existing resources? #1270
Comments
I'm here because of the same thing. I was going to use kubebuilder 2.2.0 to create some mutating webhooks for Pods and Services. I've done this before in v1 and came here after I could not even run make after initializing the project. #1213 states that native objects are not supported. I would like to see support for native k8s objects added back to kubebuilder. They worked in v1 when it was an alpha feature. In v1 of kubebuilder this worked. kubebuilder init --domain example.com --license none --owner "bob"
kubebuilder alpha webhook --group core --version v1 --kind Service --type=validating --operations=create,update I was hoping this would work in v2 but it does not. kubebuilder init --domain example.com --license none --owner "bob"
kubebuilder create webhook --group core --version v1 --kind Service --defaulting --programmatic-validation |
@adampl some answers to help you.
Yes absolutely. Only change would be: when you run $ kubebuilder create api --group "core" --kind "Service" --version "v1"
Create Resource [y/n]
n
Create Controller [y/n]
y
Yes. |
@mengqiy Can you pl. help @gregsidelinger with the webhook query ? |
@gregsidelinger Thanks for your feedback. Sorry for the late response. At the moment, kubebuilder CLI doesn't provide much scaffolding for built-in types and you have to do it through the low-level library (controller-runtime). It's still doable. Here is an example. |
We will need to add some document to at least make https://github.com/kubernetes-sigs/controller-runtime/tree/master/examples/builtins more discoverable. |
Personally, this is the best example: |
I've looked over the docs links. I'm going to work on my validating hook one of these days to see how to do it in v2 of kubebuilder. The part that really bugs me for existing objects is I need to do a bunch of extra work that I did not need to do in v1 back in the alpha days. I have a co-worker who did a mutating webhook for nodes to add AWS tags as labels and he gave up on kubebuilder 2 and use 1 instead because it was much more difficult to work with existing objects in version 2. |
@gregsidelinger can you clarify what you mean? A v1 webhook should look more-or-less identical to a v2 low-level webhook: compare https://book-v1.book.kubebuilder.io/beyond_basics/sample_webhook.html#implementing-webhook-handler with |
@droot Does that method work only for core group? I'm trying to create a controller for an istio CRD and I get errors.
After removing all API related code -
|
Hi @harpratap, This issue is close, could you please raise a new one with your questions and specific scenario? |
I'm going through the book, but it's all about CRDs so I feel a bit lost, because I don't need a CRD.
Is it actually possible to create a custom controller for an existing resource (like built-in Service or Pod) with Kubebuilder?
Is it a good idea to use Kubebuilder for this purpose?
How to do it the simple way?
I think a tutorial should be added covering this topic, or at least a short note answering these questions.
If it's not currently possible, please consider adding such feature.
/kind feature
/kind documentation
The text was updated successfully, but these errors were encountered: