{"id":13647462,"url":"https://github.com/willthames/kubernetes-validate","last_synced_at":"2025-04-04T21:07:25.483Z","repository":{"id":41297326,"uuid":"140715086","full_name":"willthames/kubernetes-validate","owner":"willthames","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-28T10:02:14.000Z","size":3704,"stargazers_count":49,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T20:07:25.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willthames.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-12T13:13:30.000Z","updated_at":"2025-03-22T16:47:49.000Z","dependencies_parsed_at":"2024-11-14T06:02:40.622Z","dependency_job_id":"e072861b-69b3-494f-bcf7-decfc2b73286","html_url":"https://github.com/willthames/kubernetes-validate","commit_stats":{"total_commits":90,"total_committers":7,"mean_commits":"12.857142857142858","dds":"0.33333333333333337","last_synced_commit":"16b5eb54a82ca9c6fb1b91f4446a2e73da2934ce"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willthames%2Fkubernetes-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willthames%2Fkubernetes-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willthames%2Fkubernetes-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willthames%2Fkubernetes-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willthames","download_url":"https://codeload.github.com/willthames/kubernetes-validate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249524,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:03:34.720Z","updated_at":"2025-04-04T21:07:25.465Z","avatar_url":"https://github.com/willthames.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# kubernetes-validate\n\nkubernetes-validate validates Kubernetes resource definitions against the\ndeclared Kubernetes schemas.\n\nBased on Gareth Rushgrove's excellent work providing a basis for turning Kubernetes\nSwagger API definitions into JSONSchema definitions, kubernetes-validate will report\non mismatches between schema defnition and resource definition\n\nNote that this currently uses a fork of kubernetes-json-schema for the following reasons:\n* Add API versions into schema names (built using https://github.com/garethr/openapi2jsonschema/pull/11)\n* [Increase coverage of strict versions](https://github.com/garethr/kubernetes-json-schema/pull/8)\n* [Update to latest Kubernetes released API versions](https://github.com/garethr/kubernetes-json-schema/pull/8)\n* Provide local-strict schemas\n* Reduce Kubernetes version support (v1.5 and v1.6 schemas are not included to reduce\n  library size and schema build time)\n\nFurthermore, the module now includes only the .0 API schemas, as they change so little within a Kubernetes\nversion (there are some differences but they seem to be mostly irrelevant to validation - e.g. description\nupdates). This has taken the module down from 300MB to less than 30MB.\n\nIf the relevant PRs get accepted upstream, then this will revert to the upstream fork.\n\n## Installation\n\npip install kubernetes-validate\n\n## Usage\n\n### Command line\n\n```\n$ kubernetes-validate\nusage: kubernetes-validate [-h] [-k KUBERNETES_VERSION] [--strict] [--version]\n                           ...\n\nvalidate a kubernetes resource definition\n\npositional arguments:\n  filenames\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -k KUBERNETES_VERSION, --kubernetes-version KUBERNETES_VERSION\n                        version of kubernetes against which to validate.\n                        Defaults to major/minor version of kubernetes-validate\n                        (i.e. 1.22.1 supports kubernetes 1.22). Patch versions\n                        of the version are ignored (1.22.4 validates against\n                        1.22.0)\n  --strict              whether to use strict validation, rejecting unexpected\n                        properties\n  --quiet               whether to only output warnings/failures\n  --no-warn             whether to hide warnings\n  --version             show program's version number and exit\n```\n\ne.g.\n\n```\n$ kubernetes-validate -k 1.27 --strict resource.yml\n```\n\n### Python\n\n```\nfrom __future__ import print_function\nimport kubernetes_validate\nimport yaml\n\ntry:\n    data = yaml.load(open('resource.yaml').read())\n    kubernetes_validate.validate(data, '1.22', strict=True)\nexcept kubernetes_validate.ValidationError as e:\n    print(''. join(e.path), e.message)\n```\n\n### Examples\n\n```\n$ kubernetes-validate -k 1.21 examples/kuard-extra-property.yaml\nINFO  examples/kuard-extra-property.yaml passed against version 1.21\n```\n\n```\n$ kubernetes-validate --strict examples/kuard-extra-property.yaml\nERROR examples/kuard-extra-property.yaml did not validate against version 1.28.0: spec.selector: Additional properties are not allowed ('unwanted' was unexpected)\n```\n\n```\n$ kubernetes-validate examples/kuard-invalid-type.yaml\nERROR examples/kuard-invalid-type.yaml did not validate against version 1.28.0: spec.replicas: 'hello' is not of type u'integer'\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillthames%2Fkubernetes-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillthames%2Fkubernetes-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillthames%2Fkubernetes-validate/lists"}