K8s Manifest Validator
Prerequisites & Dependencies
- Python 3.10+ (for YAML/JSON parsing)
kubectlfor Kubernetes cluster interaction (optional, for validation)jqfor JSON parsing (optional)
Execution Steps
Parse the Kubernetes manifest: Read the YAML or JSON file containing the Kubernetes resource definition.
Validate required fields: Check for essential fields like
apiVersion,kind,metadata.name, and appropriatespecstructure based on the resource type.Check resource constraints: Validate CPU/memory requests and limits, replica counts, and service account settings.
Generate validation report: Output a structured report listing:
- Valid fields and structures
- Missing or invalid fields
- Warnings for deprecated or recommended settings
- Suggested fixes for common issues
Optional kubectl dry-run: If
kubectlis available, runkubectl apply --dry-run=clientto validate the manifest against the cluster's schema.Example output: A validation report indicating the manifest is valid, or listing issues like missing
selector, incorrectapiVersion, or impropermetadataformatting.
kubectl apply --dry-run=client -f manifest.yaml