Conversion and finalizers
Separate served versions from storage
A custom API may serve multiple versions of the same logical resource. Each version has a served flag that controls API access through that version and a storage flag indicating the version used for new persistence. Exactly one version must be designated as storage. An object retrieved using a served version may be converted from its stored representation; it is not a separate object per version. The CRD status.storedVersions records versions that have been storage versions and can still be relevant to migration.
Initial: v1alpha1 served=true storage=trueTransition: v1alpha1 served=true storage=false; v1 served=true storage=trueExisting persisted objects: possibly still v1alpha1Conversion is not storage migration
The None conversion strategy is suitable only when changing the version identifier is sufficient; it does not transform renamed or restructured fields. A Webhook strategy calls a conversion service when conversion is required. For example, changing spec.quantity to spec.copies needs an explicit mapping that preserves meaning across versions. Test both directions, defaulting interactions, round trips and failure handling. Do not silently drop fields older clients need. A failed conversion service can break reads and writes for affected versions; secure and monitor it. No conversion webhook is deployed here.
Illustrative mapping only:v1alpha1.spec.copies = 3 ↔ v1.spec.quantity = 3Same request identity; no duplicated orderPlan a migration without losing old data
First inventory clients, schemas, persisted versions, backups and conversion availability. Serve the new version and verify compatibility. Switch storage only after the conversion path and consumers are ready. Rewrite or migrate existing objects using a supported version-specific workflow; merely changing storage=true does not rewrite existing objects. Verify completion before removing the old version from status.storedVersions. Stop serving the old API when consumers are migrated, and remove its version declaration only after storage and client checks. Migration tooling is version-dependent; the current documentation includes a StorageVersionMigration API, but the inherited baseline is not verified in this environment.
Gate before removing v1alpha1:no old clients requiring itno old persisted records remainingold version absent from status.storedVersionsverified conversion and recovery planFinalizers delay removal
A finalizer is a key on an object that identifies a cleanup obligation. When a deletion request is accepted for an object with finalizers, the API records a deletionTimestamp and retains the object until remaining finalizers are removed. A controller may then clean up its owned external state and remove its own key after success. A finalizer is not executable code. Cleanup must be idempotent so retries are safe. If the responsible controller is unavailable, deletion can wait indefinitely. Never remove an unfamiliar finalizer simply to make an object disappear.
metadata: name: math-books deletionTimestamp: "2026-01-01T10:00:00Z" finalizers: - books.example.com/reservation-cleanupUnderstand the impact of deleting a CRD
Removing a CRD removes its API endpoint and initiates deletion of its stored custom resources. This is not equivalent to stopping its controller. If custom resources represent real external assets, deletion and cleanup can have significant consequences. Inventory instances in every namespace, verify backups, ownership and cleanup, then follow an authorized change plan. In the offline exercise no resource is actually deleted. A lingering finalizer is a signal to inspect the responsible controller and its cleanup evidence, not an instruction to bypass it.
Safe diagnostic sequence (conceptual):inspect object → identify finalizer owner → inspect cleanup evidence→ restore responsible controller or approved recovery → verifyPractice and next step
Review version-cases.json and finalizer-cases.json. Predict which transitions are valid for the simplified migration gate and which objects are still waiting for cleanup. Explain why switching storage does not prove migration completed, and why an empty finalizer list alone is not proof of external cleanup. Next: custom resource validation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Conversion and finalizers — knowledge check
Reason about served and storage versions, conversion, migration and safe finalizer-based deletion.
How many versions of one CRD can have storage=true?
What happens to old persisted objects when the storage flag changes?
A field is renamed between versions. What is required to preserve its meaning?
Why can a resource with a deletionTimestamp still exist?
When is it safe to remove an old version declaration in the example migration gate?