Skip to content
Back to skills

Kubernetes Crd Storage Version Audit

ASecurity

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

  • 50,717 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentspythongokubernetesgitapidevops

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add sickn33/agentic-awesome-skills --skill kubernetes-crd-storage-version-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kubernetes Crd Storage Version Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kubernetes Crd Storage Version Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sickn33-kubernetes-crd-storage-version-audit/badge)](https://www.skillsdirectory.com/skills/sickn33-kubernetes-crd-storage-version-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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:
- `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](references/crd-storage-audit-harness.md):

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](references/crd-storage-audit-harness.md):

```text
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

- [Kubernetes Docs — Versions in CustomResourceDefinitions](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/)
- Related skills: [kubernetes-ops](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/kubernetes-ops/SKILL.md), [kubernetes-deployment](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/kubernetes-deployment/SKILL.md), [helm-chart-scaffolding](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/helm-chart-scaffolding/SKILL.md), [gitops-workflow](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/gitops-workflow/SKILL.md).

Files in this skill

  • SKILL.md8.3 KB
  • references/crd-storage-audit-harness.md29.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.