← LeaderboardThe Skill Leaderboard

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.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: kubernetes-crd-storage-version-auditdescription: "Audit Kubernetes CustomResourceDefinition storage version changes read-only against saved status.storedVersions, served flags, conversion webhooks, and safe migration steps."category: devopsrisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [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:

  • kubernetes-ops: covers live cluster workload deployments, scaling, Services, and kubectl operations rather than offline CRD storage/storedVersions schema transitions.
  • kubernetes-deployment: orchestrates application rollout workflows (container build, Helm, mesh) without validating CRD version removal preconditions.
  • helm-chart-scaffolding: packages Helm charts and templates rather than auditing saved CRD status against replacement spec.versions.
  • gitops-workflow: manages ArgoCD/Flux continuous reconciliation rather than checking CRD conversion strategy and status.storedVersions migration blockers.

When to Use

  • Before removing a deprecated version (such as v1beta1) from a Kubernetes CRD's spec.versions.
  • Before switching storage: true from one CRD API version to another.
  • When reviewing whether a proposed CRD change requires a Webhook conversion strategy and conversionReviewVersions.
  • Do not use this skill to patch live cluster CRDs, rewrite etcd objects, edit status.storedVersions directly, or delete CRDs in a cluster.

Prerequisites

  • Python 3.10+ with pinned test/YAML dependencies (tested with Python 3.12.10, PyYAML==6.0.3, pytest==9.1.1).
  • A saved current CRD YAML export (including status.storedVersions) and the proposed replacement CRD YAML manifest.
  • No live Kubernetes cluster access, kubeconfig, or cluster write permissions required.

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:
    • Missing, non-list, or empty status.storedVersions in the current CRD produces MISSING_STATUS_EVIDENCE (FAIL under strict audit), never an assumption that zero stored versions exist.
    • Even when status.storedVersions lists only the new storage version, explicitly record a stale-status caveat: a saved static status snapshot cannot prove every custom resource object across namespaces was rewritten at the new version without cluster-side object/StorageVersion verification.
  4. Served vs. storage semantics & conversion prerequisites:
    • Setting an old version to served: false, storage: false while retaining it in spec.versions is allowed as an intermediate deprecation stage while storage migration completes.
    • Whenever conversion.strategy: Webhook is configured (regardless of spec.versions count), require a conversion.webhook mapping with a valid clientConfig matching WebhookClientConfig (exactly one of service or url, never both or neither: service requires non-empty name and namespace, optional integer port in 1..65535, and optional path starting with /; url requires a well-formed https:// URL with host and no whitespace/control characters, rejecting http://, malformed URLs, user information, query parameters, and fragments) — emitting an additional UNNECESSARY_WEBHOOK warning if only one version remains.
    • Distinguish Kubernetes API-server requirements (where apiextensions.k8s.io/v1 permits conversionReviewVersions with "v1" or "v1beta1") from this harness's stricter modern v1 ConversionReview policy, first validating that conversion.webhook.conversionReviewVersions is a non-empty list where every element is a non-empty string before requiring "v1". Flag strategy: None across multi-version schema changes as an explicit warning/review gate.

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

  • Read-only manifest analysis checks a saved YAML export only; status.storedVersions in a snapshot can be stale relative to live etcd objects or pending StorageVersion migrations.
  • Passing this check does not validate OpenAPI v3 structural schema field compatibility across versions or test live webhook TLS connectivity/runtime behavior.
  • Does not inspect live StorageVersion (internal.apiserver.k8s.io/v1alpha1) resources or cluster admission webhooks.

Safety and Side Effects

  • Strictly offline and read-only (yaml.safe_load only — never yaml.load / arbitrary Python tag execution).
  • Never executes kubectl apply, kubectl patch, kubectl delete crd, or status subresource writes.

Sources and related skills