contributing/guide-api-promotion.md
This guide describes the process for promoting an API in Crossplane from one version to the next. This process should be handled with care over multiple releases, as it has proven fairly easy for Crossplane's API promotions of the past to be problematic for both upgrades and downgrades, as demonstrated by #6148, #5932, and #4400.
An explanation of Crossplane's feature lifecycle can be found in the Feature Lifecycle docs page.
The root cause we have encountered in past problematic API promotions is that we try to drop a particular version from a CRD while there may still be resources of that version stored in etcd. Kubernetes does not allow this action because it can result in possible data loss.
Note that this can happen on both upgrades as well as downgrades. Let's briefly summarize one common downgrade path where we've encountered this issue:
status.storedVersions fieldThere are a few simple principles we can follow in order to avoid this common scenario when promoting Crossplane APIs:
Adherence to these two principles should result in never dropping a CRD version that still has resources of that version stored in etcd, for both the upgrade and downgrade directions.
The following table outlines the steps to introduce and then promote an API safely across multiple versions while maintaining safe upgrades and downgrades:
| Version | Description | Alpha | Beta | Migration |
|---|---|---|---|---|
| v0.1 | introduce new API as alpha | storage, served | not exist | none |
| v0.2 | promote to beta | storage, served | served | migrate to alpha |
| v0.3 | bump storage to beta | served | storage, served | migrate to beta |
| v0.4 | drop alpha | not exist | storage, served | none |
The same process could be applied again when promoting the API from Beta to v1 GA.
This section contains some helpful pointers to areas of the codebase involved in promoting an API. These are just general direction and not entirely prescriptive, because you'll need to make specific decisions for your promotion based on the workflow defined above.
apis directory, for example
apis/apiextensions/v1beta1+kubebuilder:storageversion marker on the correct
version, e.g., as shown here for Usage v1alpha1generate.go, also
instructing the duplicate script to set the storage version if needed./nix.sh run .#generate to generate the CRDs and check them for sanity
in the cluster/crds directory