Comprehensive toolkit for validating, linting, and testing Kubernetes YAML resources. Use this skill when validating Kubernetes manifests, debugging YAML syntax errors, performing dry-run tests on clusters, or working with Custom Resource Definitions (CRDs) that require documentation lookup.
Overall
score
93%
Does it follow best practices?
Validation for skill structure
This document outlines the comprehensive validation workflow for Kubernetes YAML resources.
Purpose: Catch YAML syntax errors and style issues before Kubernetes-specific validation.
Command:
yamllint <file.yaml>Common Issues Detected:
Configuration:
Create a .yamllint config file for custom rules:
extends: default
rules:
line-length:
max: 120
indentation:
spaces: 2
comments:
min-spaces-from-content: 1Purpose: Validate against Kubernetes schemas and detect structural issues.
Basic Command:
kubeconform -summary <file.yaml>With CRD Support (recommended):
kubeconform \
-schema-location default \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
-strict \
-ignore-missing-schemas \
-summary \
-verbose \
<file.yaml>Options:
-strict: Reject resources with unknown fields (catches typos - recommended for production)-ignore-missing-schemas: Skip validation for CRDs without available schemas-kubernetes-version <version>: Validate against specific K8s version (e.g., 1.30.0)-output json: Output results as JSONCommon Issues Detected:
Purpose: Validate against the actual cluster configuration, admission controllers, and policies.
Client-Side Dry Run:
kubectl apply --dry-run=client -f <file.yaml>Server-Side Dry Run:
kubectl apply --dry-run=server -f <file.yaml>Diff Mode (for updates):
kubectl diff -f <file.yaml>Shows what would change if applied to the cluster.
Use the detect_crd.py script:
python3 scripts/detect_crd.py <file.yaml>Output example:
[
{
"kind": "Certificate",
"apiVersion": "cert-manager.io/v1",
"group": "cert-manager.io",
"version": "v1",
"isCRD": true,
"name": "example-cert"
}
]For each detected CRD:
Use context7 MCP (preferred):
mcp__context7__resolve-library-id with the CRD group/project namemcp__context7__get-library-docs with the library IDFallback to Web Search:
"<kind>" "<group>" kubernetes CRD "<version>" documentation"Certificate" "cert-manager.io" kubernetes CRD "v1" documentationOnce documentation is found:
┌─────────────────────────────────────────────────────────────┐
│ 1. Check Tools │
│ Run: scripts/setup_tools.sh │
│ Ensure yamllint, kubeconform, kubectl are installed │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 2. YAML Syntax Check │
│ Run: yamllint <file.yaml> │
│ Fix: Indentation, trailing spaces, syntax errors │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 3. Detect CRDs │
│ Run: python3 scripts/detect_crd.py <file.yaml> │
│ Parse: Extract kind, apiVersion, group │
└─────────────────────────────────────────────────────────────┘
↓
┌──────┴──────┐
│ │
[CRD?] [Standard Resource]
│ │
↓ ↓
┌──────────────────────┐ │
│ 4a. Lookup CRD Docs │ │
│ - context7 MCP │ │
│ - Web search │ │
│ - Version-aware │ │
└──────────────────────┘ │
│ │
└──────┬──────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 5. Schema Validation │
│ Run: kubeconform -summary <file.yaml> │
│ Fix: Required fields, types, unknown fields │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 6. Dry-Run (if cluster available) │
│ Run: kubectl apply --dry-run=server -f <file.yaml> │
│ Fix: Admission issues, quotas, policies │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 7. Generate Validation Report │
│ - Summarize all issues in table format │
│ - Show before/after code blocks for each issue │
│ - Do NOT modify files - report only │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ 8. Provide Next Steps │
│ - List errors that must be fixed │
│ - List warnings for best practices │
│ - User decides which fixes to apply │
└─────────────────────────────────────────────────────────────┘scripts/setup_tools.sh to check tool availabilitykubectl get crd <crd-name> -o yamlGenerate a comprehensive validation report with all findings. Do NOT modify files.
Header with issue count
## Validation Report - 7 issues found (4 errors, 3 warnings)Issues Summary Table
| Severity | Stage | Location | Issue | Suggested Fix |
|----------|-------|----------|-------|---------------|
| Error | Syntax | file.yaml:8 | Wrong indentation | Use 2 spaces |
| Error | Schema | file.yaml:21 | Wrong type | Change to integer |
| Warning | Best Practice | file.yaml:30 | Missing labels | Add app label |Detailed Findings (for each issue)
Validation status by stage
Next Steps
## Validation Report - 7 issues found
File: deployment.yaml
Resources Analyzed: 3 (Deployment, Service, Certificate)
| Stage | Status | Issues |
|-------|--------|--------|
| YAML Syntax | ❌ Failed | 2 errors |
| CRD Detection | ✅ Passed | 1 CRD found |
| Schema Validation | ❌ Failed | 2 errors |
| Dry-Run | ❌ Failed | 1 error |
### Issue 1: deployment.yaml:8 - Wrong indentation (Error)
Current:
```yaml
labels:Suggested Fix:
labels:Why: Kubernetes YAML requires 2-space indentation.
Current:
- containerPort: "80"Suggested Fix:
- containerPort: 80Why: containerPort must be an integer, not a string.
[... more issues ...]
### Report Best Practices
- **Be specific:** List every issue with exact location
- **Show both current and suggested:** Always show before/after code blocks
- **Explain impact:** Help user understand why each issue matters
- **Group by file:** When multiple files are involved
- **Prioritize by severity:** Errors first, then warnings, then info
- **Provide file references:** Always include file:line for traceability
- **Clear next steps:** Tell user exactly what to doInstall with Tessl CLI
npx tessl i pantheon-ai/k8s-yaml-validator@0.1.0