Kubernetes schemas#
When a value flows into a built-in Kubernetes resource field, helm-schema types it from the upstream Kubernetes JSON schema for that resource. This is what turns spec.replicas into an int32 with the API’s own description, or a resources block into the full ResourceRequirements shape.
Schemas are fetched on demand from the upstream catalog and cached locally. The upstream source is authoritative; the cache only makes repeat lookups fast.
Choosing the version#
helm-schema ./mychart --k8s-version v1.34.0--k8s-version selects the Kubernetes minor version whose schemas are consulted. The default is v1.35.0.
The flag is repeatable and order matters: the first value is the primary version, and any further values are explicit fallbacks consulted in order when the primary doesn’t hold a resource.
# Try 1.34 first, then fall back to 1.28 for anything 1.34 lacks
helm-schema ./mychart --k8s-version v1.34.0 --k8s-version v1.28.0Automatic version fallback#
Charts in the wild still ship resources on APIs that were removed from recent Kubernetes — for example policy/v1beta1 (PodDisruptionBudget) or networking.k8s.io/v1beta1 (Ingress), both removed in v1.25. --k8s-version-fallback auto-extends a single --k8s-version with older minors so those lookups still resolve:
# Extend the primary version with a default-sized window of older minors
helm-schema ./mychart --k8s-version-fallback auto
# Or an explicit number of older minors
helm-schema ./mychart --k8s-version-fallback 5auto uses a default window (15 minors), sized to cover the realistic deprecation horizon. The lookup then falls back through v1.34.0 → v1.33.0 → … until it finds the schema.
- It is mutually exclusive with
--strict-k8s-version, and is rejected if combined with multiple explicit--k8s-versionvalues (spell the list out explicitly in that case). - Auto-fallback versions are an escape valve for the schema-lookup layer only. They do not participate in apiVersion inference, so a chart missing an
apiVersionwon’t silently pick up a fallback’s deprecated API and become ambiguous.
--strict-k8s-version disables the auto-fallback chain entirely:
helm-schema ./mychart --strict-k8s-versionMirrors#
Add alternate upstream sources with --k8s-schema-mirror (repeatable). Mirrors are alternate exact-version sources, not heuristics, so they work in both strict and loose modes. Per-source cache namespacing keeps a mirror’s entries from masking the default catalog — the default catalog always wins at lookup time.
helm-schema ./mychart --k8s-schema-mirror https://my.mirror/schemasWorking offline#
The cache makes fully offline runs possible once it is warm. To guarantee no network access:
helm-schema ./mychart \
--offline \
--k8s-schema-cache-dir ./k8s-schema-cache \
--output values.schema.json--offlinedisables all network access and uses only local caches. (Equivalent to settingHELM_SCHEMA_ALLOW_NET=0.)--k8s-schema-cache-dirpoints at a managed cache root you control — warm it once online, then reuse it in a sealed environment. See Caching.--no-cachedoes the opposite: bypass cache reads and re-check upstream directly (successful responses and authoritative 404s still refresh the cache, so this repairs stale entries).
To skip Kubernetes schemas altogether and rely purely on template analysis:
helm-schema ./mychart --no-k8s-schemasThis is fully offline and deterministic, and is the right choice when you only care about the template-implied shape.
apiVersion inference#
To type a resource field, the analyzer needs the resource’s apiVersion and kind. It recovers these structurally from the manifest whenever possible — including across if/else branches and from helpers that resolve to a finite set of literals.
When the apiVersion genuinely can’t be pinned (it’s templated or absent), the lookup normally fails with apiVersion unknown. --api-version-guess enables a bounded, three-tier inference:
- a hardcoded canonical
kind → apiVersionshortlist for unambiguous Kubernetes and Prometheus-operator kinds, - a scan across the configured local caches,
- a kind-scoped probe against the CRD catalog mirrors (only for kinds in the extended shortlist — no blind group sweeps).
helm-schema ./mychart --api-version-guessWhen exactly one apiVersion is implied, it emits an InferredApiVersion diagnostic. When several are plausible (e.g. Ingress in both networking.k8s.io/v1 and extensions/v1beta1), it abstains and emits AmbiguousApiVersion rather than guessing wrong.
--strict-api-versions disables inference entirely (mutually exclusive with --api-version-guess), so an unpinnable apiVersion is always left unresolved.