Home / Market / kubernetes crd storage version audit

kubernetes crd storage version audit

Audit Kubernetes CustomResourceDefinition storage version changes read-only against saved status.storedVersions, served flags, conversion webhooks, and safe migration steps.

skill★ 508830 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: kubernetes-crd-storage-version-audit description: "Audit Kubernetes CustomResourceDefinition storage version changes read-only against saved status.storedVersions, served flags, conversion webhooks, and safe migration steps." category: devops risk: safe source: self source_type: self date_added: "2026-12-01" author: Koushik-Katkam tags: [kubernetes, crd, storage-version, migration, validation, audit]

---

Kubernetes CRD Storage Version Audit

Overview

Perform a strictly read-only pre-flight audit comparing a saved current Kubernetes CustomResourceDefinition (apiextensions.k8s.io/v1) YAML manifest against a proposed replacement CRD manifest before changing served/storage versions or removing an old API version.

Distinction from existing Kubernetes skills:

When to Use

Prerequisites

How It Works

1. Validate inputs and CRD API version bounds

  1. Parse both YAML files strictly with yaml.safe_load and reject multi-document streams or non-mapping documents as INVALID_INPUT.
  2. Require kind: CustomResourceDefinition, validate metadata, spec, spec.names, and status (when present) as mappings before accessing fields, and reject legacy apiextensions.k8s.io/v1beta1 CRDs as UNSUPPORTED rather than applying v1 field assumptions.
  3. Require identical (metadata.name, spec.group, spec.names.plural, spec.scope) CRD identity between current and proposed manifests.

2. Audit version flags, storedVersions, and conversion strategy

Run the local verification suite in CRD storage version audit harness:

  1. Single storage version rule: Verify both current and proposed CRDs have exact count = 1 entry with storage: true and valid boolean served / storage fields across all spec.versions.
  2. Stored versions vs. proposed & current specs: Check all entries in current status.storedVersions against both current.spec.versions and proposed.spec.versions (not merely the removed-version set), and verify current storage: true appears in status.storedVersions. Any stored version absent from proposed.spec.versions (REMOVED_STORED_VERSION or ORPHANED_STORED_VERSION), absent from current.spec.versions (STORED_VERSION_NOT_IN_CURRENT_SPEC), or missing the current storage version (INCONSISTENT_CURRENT_STORAGE_EVIDENCE) must FAIL.
  3. Missing or stale status handling:
  1. Served vs. storage semantics & conversion prerequisites:

3. Emit safe migration sequencing

Report the ordered Kubernetes CRD storage migration sequence whenever an old version remains in status.storedVersions:

  1. Add the new version (served: true, storage: false) and deploy conversion webhook if schemas differ.
  2. Promote the new version to storage: true (demoting old version to storage: false, optionally served: false).
  3. Re-read and re-write all existing custom resources at the new storage version (e.g., Storage Version Migrator or authorized controller).
  4. Verify live cluster objects are migrated and reconcile status.storedVersions before removing the old version from spec.versions.

Examples

Run the self-contained verification suite in CRD storage version audit harness:

User request: "Can we safely drop v1beta1 from our Widget CRD manifest in this release PR?"
Inputs: Saved current Widget CRD YAML (with status.storedVersions) and proposed v1-only Widget CRD YAML.
Expected result: PASS with stale-status caveat when status.storedVersions == ["v1"] and proposed v1 has storage: true;
  FAIL with REMOVED_STORED_VERSION when v1beta1 remains in status.storedVersions; FAIL on 0 or >1 storage versions
  or incomplete Webhook conversion config.

Limitations

Safety and Side Effects

Sources and related skills