Skip to main content

kubernetes-validate

kubernetes-validate validates Kubernetes resource definitions against the declared Kubernetes schemas.

Based on Gareth Rushgrove's excellent work providing a basis for turning Kubernetes Swagger API definitions into JSONSchema definitions, kubernetes-validate will report on mismatches between schema defnition and resource definition

Note that this currently uses a fork of kubernetes-json-schema for the following reasons:

Furthermore, the module now includes only the .0 API schemas, as they change so little within a Kubernetes version (there are some differences but they seem to be mostly irrelevant to validation - e.g. description updates). This has taken the module down from 300MB to less than 30MB.

If the relevant PRs get accepted upstream, then this will revert to the upstream fork.

Installation

pip install kubernetes-validate

Usage

Command line

$ kubernetes-validate
usage: kubernetes-validate [-h] [-k KUBERNETES_VERSION] [--strict] [--version]
                           ...

validate a kubernetes resource definition

positional arguments:
  filenames

optional arguments:
  -h, --help            show this help message and exit
  -k KUBERNETES_VERSION, --kubernetes-version KUBERNETES_VERSION
                        version of kubernetes against which to validate.
                        Defaults to major/minor version of kubernetes-validate
                        (i.e. 1.22.1 supports kubernetes 1.22). Patch versions
                        of the version are ignored (1.22.4 validates against
                        1.22.0)
  --strict              whether to use strict validation, rejecting unexpected
                        properties
  --quiet               whether to only output warnings/failures
  --no-warn             whether to hide warnings
  --version             show program's version number and exit

e.g.

$ kubernetes-validate -k 1.27 --strict resource.yml

Python

from __future__ import print_function
import kubernetes_validate
import yaml

try:
    data = yaml.load(open('resource.yaml').read())
    kubernetes_validate.validate(data, '1.22', strict=True)
except kubernetes_validate.ValidationError as e:
    print(''. join(e.path), e.message)

Examples

$ kubernetes-validate -k 1.21 examples/kuard-extra-property.yaml
INFO  examples/kuard-extra-property.yaml passed against version 1.21
$ kubernetes-validate --strict examples/kuard-extra-property.yaml
ERROR examples/kuard-extra-property.yaml did not validate against version 1.28.0: spec.selector: Additional properties are not allowed ('unwanted' was unexpected)
$ kubernetes-validate examples/kuard-invalid-type.yaml
ERROR examples/kuard-invalid-type.yaml did not validate against version 1.28.0: spec.replicas: 'hello' is not of type u'integer'

Metadata

Release files for kubernetes-validate 1.37.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubernetes-validate 1.37.0
File Size Uploaded
kubernetes_validate-1.37.0.tar.gz 11.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for kubernetes-validate 1.37.0
File Interpreter ABI Platform
kubernetes_validate-1.37.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 MB

Release files / kubernetes_validate-1.37.0.tar.gz

Download URL kubernetes_validate-1.37.0.tar.gz
Size 11.0 MB
Tags Source
SHA-256 checksum
How to use checksums
09a26209d3e32d97ac13e6f81597c09316fe6f7473cdd4bd8db44075930de357
BLAKE2b-256 checksum
How to use checksums
cd14e6b287f114457bd958cc3f520bd36a474e6a9ffc92a89aca8329da173eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / kubernetes_validate-1.37.0-py3-none-any.whl

Download URL kubernetes_validate-1.37.0-py3-none-any.whl
Size 22.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
85136d018a27b50ec7fc049d902bfa5193f5976807e6c0f408e3ab6fe078cad9
BLAKE2b-256 checksum
How to use checksums
b050104f3b5a41aba6737c5f2ffe76270398f3a7320dc4a4f3f88dfd5bc9af63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.37.0 This release

2 release files

1.36.0

2 release files

1.34.1

2 release files

1.34.0

2 release files

1.33.1

2 release files

1.32.0

2 release files

1.31.0

2 release files

1.30.0

2 release files

1.29.1

2 release files

1.28.3

2 release files

1.28.2

2 release files

1.28.0

2 release files

1.27.1

1 release file

1.27.0

1 release file

1.26.0

1 release file

1.25.2

1 release file

1.25.1

1 release file

1.24.1

1 release file

1.24.0

1 release file

1.23.4

1 release file

1.23.3

1 release file

1.23.2

1 release file

1.23.1

1 release file

1.23.0

1 release file

1.22.3

1 release file

1.22.1

1 release file

1.22.0

1 release file

1.21.0

1 release file

1.20.0

1 release file

1.19.0

1 release file

1.18.0

1 release file

1.16.0

1 release file

1.13.0

1 release file

1.12.2

1 release file

1.12.1

1 release file

1.12.0

1 release file

1.11.5

1 release file

1.11.4

1 release file

1.11.3

1 release file

1.11.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page