Registry / devops / kubernetes-validate

kubernetes-validate

JSON →
library1.36.0pypypi✓ verified 85d ago

Validates Kubernetes resource definitions (YAML/JSON) against the schemas from the Kubernetes OpenAPI specification. Current version 1.35.0 supports Kubernetes 1.35. Supports Python >=3.7. Released approximately twice a year to match Kubernetes minor versions.

pip install kubernetes-validate
INSTALL
IMPORT
SIG · KUBERNETES-VALIDAT
K
kubernetes-validate
devopspythonv1.36.0
Install
5.3s avg
Import
404ms
Disk
122MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.36.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.412s · 123.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.3s · import 0.396s · 124MB
122MB installed
● package 122MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validate
from kubernetes_validate import validate
from kubernetes_validate import validator
No direct 'validator' symbol exists; use 'validate' function.
validation_failures
from kubernetes_validate.utils import validation_failures
from kubernetes_validate import validation_failures
validation_failures is in the utils module, not top-level.

Validates a Kubernetes YAML resource against the schema for a specific API version and Kubernetes version.

from kubernetes_validate import validate import yaml with open('deployment.yaml') as f: resource = yaml.safe_load(f) failures = validate(resource, 'apps/v1', 'Deployment', '1.35') if failures: for f in failures: print(f) else: print('Resource is valid')
kubernetes-validate --version
Debug
Known issues
breakingkubernetes-validate v1.29.0 removed support for Kubernetes v1.20 and v1.21. If you rely on those versions, pin to v1.28.1 or earlier.
fix
Pin version: pip install 'kubernetes-validate<1.29'
affects: >=1.29.0
breakingFrom v1.29.0, the JSON schemas changed completely to use a newer schema version, requiring the 'referencing' library. Old schema files may not be compatible.
fix
Update any custom schema files to the new format or use the bundled schemas.
affects: >=1.29.0
gotchaThe validate function returns an empty list (not None) on success. Checking 'if not failures:' works, but comparing to None will fail.
fix
Use 'if failures:' or 'if len(failures) > 0' to detect validation errors.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'kubernetes_validate'
Package name has an underscore, but pip installation uses 'kubernetes-validate' (hyphen).
fix
Run: pip install kubernetes-validate
KeyError: 'apiVersion'
The input resource dict does not contain 'apiVersion', 'kind', or 'metadata'. The validate function requires these keys.
fix
Ensure the resource dictionary has the standard Kubernetes fields, e.g., from yaml.safe_load of a valid manifest.
kubernetes_validate.utils.validation_failures object has no attribute '__iter__'
validation_failures is a class, not a function. The correct usage is to instantiate it or use the validate function directly.
fix
Use 'from kubernetes_validate import validate' and call 'validate(...)' which returns a list of failures.
Upgrade
Version history
1.36.0latest on PyPI · released May 18, 2026
Audit
Dependencies
PyYAMLrequiredRequired for parsing YAML files.
jsonschemarequiredUsed for JSON Schema validation.
referencingrequiredRequired for schema referencing in newer versions (v1.29+).
Agent activity
26 hits · last 30 days
node
20
OpenAI (training)
1
Resources
kubernetes-validate — pip install kubernetes-validate · libregistry