youtube image
From YouTube: How to write API conversions for Kubernetes CRDs?

Description

In all open source projects like Cluster API and its providers we initially start with alpha releases, however, eventually, most of these projects will need to move to a more stable API and that's why they made multiple releases and introduced some changes in the existing APIs. Since now we support different versions, and users can request either version, so we need to define a way to convert between our versions. These API changes can include addition, deletion and renaming of some existing and new fields in the existing CRDs, but while introducing these changes we need to make sure we should not break and continue the support for older versions. So to attain this stability we need to write some conversion functions and to understand the logic behind these, we first need to understand Hubs, Spokes and other wheel metaphors that are heavily used in writing those conversion functions.
A simple approach to defining conversion might be to define conversion functions to convert between each of our versions. Then, whenever we need to convert, we’d look up the appropriate function, and call it to run the conversion. This approach works fine when we just have two versions, but what if we had 4 types? 8 types? That’d be a lot of conversion functions. So to understand this problem and unblock all the new contributors, we want to present this talk where we can brief the concepts used to write the conversion function and also give a demonstration of how you can update any API and extend the support for older versions.