[QUESTION] What is the best practice of updating CRD fields? #3531
-
If I want to add a field in a exist CRD, can I just add the field without creating a new CRD version? And If the best practice is to create a new CRD version, when versions are more than 2, which should I set to storage/served/unserved? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Adding a Field to an Existing CRDWhen you want to change the schema of a Custom Resource, you have two main options:
CRD UpgradesWhen you make changes to a CRD and introduce a new version, you must update your operator's deployment to be aware of this new version. If the operator is set up correctly and you've provided conversion logic (if necessary), old resources will get converted to the new version upon read or write. See the tutorial: https://book.kubebuilder.io/multiversion-tutorial/tutorial Some thoughts
The "Hub" and "Spoke" ModelYou can use the "hub-and-spoke" model for conversion with webhooks:
It's generally a good idea to make the newest stable version the hub. If you introduce a |
Beta Was this translation helpful? Give feedback.
-
Closing this one as solved . Also, feel free to contribute with Kubebuilder and the docs if you need |
Beta Was this translation helpful? Give feedback.
Closing this one as solved .
However, if you see that is need please re-open
Also, feel free to contribute with Kubebuilder and the docs if you need
We have now a best practices docs as well and you can find references for the kubernetes convention api doc which can be helpful, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/reference/good-practices.md