Is it possible to have specific webhook for each version of the same kind? #3285
-
Following the book, I've created 2 versions of a kind ( When I am creating v1 or v2 resources only the v2 mutation and validation endpoints are being called. I was expecting v1 endpoints to be called for v1 resources and v2 endpoints for v2 resources. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To answer the user's question: Yes, this is the expected behavior when dealing with conversion in Kubernetes CRDs. Here's why: Storage Version: When you said v1 is the storage version, it means that all the objects of Kind Foo, irrespective of their API version, will be stored in etcd in the v1 version. So, whether you submit a v1 or v2 object to the API server, before persisting to etcd, it will be converted to the v1 version. Conversion Webhooks: The conversion webhooks are responsible for converting objects between different versions. When an object is submitted to the API server (either for reading or writing), it might need to be converted to a different version. This is where the conversion webhook comes into play. In your case, if you submit a v1 object, but you're using a v2 client (or vice versa), the conversion webhook is responsible for handling this translation. Defaulters & Validators: Here's where it gets a bit tricky. Given the setup you described, Kubernetes will: Convert the object to the Hub version (v1 in this case) using the conversion webhook. In short, the behavior you're observing is expected given Kubernetes' CRD versioning and conversion mechanisms. I hope that helps you out |
Beta Was this translation helpful? Give feedback.
To answer the user's question:
Yes, this is the expected behavior when dealing with conversion in Kubernetes CRDs. Here's why:
Storage Version:
When you said v1 is the storage version, it means that all the objects of Kind Foo, irrespective of their API version, will be stored in etcd in the v1 version. So, whether you submit a v1 or v2 object to the API server, before persisting to etcd, it will be converted to the v1 version.
Conversion Webhooks:
The conversion webhooks are responsible for converting objects between different versions. When an object is submitted to the API server (either for reading or writing), it might need to be converted to a different version. This is where the co…