What does the Kubernetes Manifest Validator & Kubeval Linter do?
The Kubernetes Manifest Validator & Kubeval Linter parses and audits Kubernetes resource manifests (Deployments, Pods, Services, Ingresses, ConfigMaps) against standard Kubernetes OpenAPI schema constraints. It splits multi-document YAML manifests separated by --- and checks mandatory fields, metadata names, replica types, container image specifications, and selector match labels.
Core Concepts
Understanding Kubernetes manifest schema validation rules:
- Mandatory Root Keys: Every valid Kubernetes manifest must define
apiVersion,kind, andmetadata.name. - Resource Kind Verification:
- Pods: Verifies
spec.containerscontains valid image references and container names. - Deployments: Validates
spec.replicasintegers,spec.selector.matchLabels, andspec.template.spec.containers. - Services: Validates
spec.portsarray with required port integers and protocol configurations.
- Pods: Verifies
- Multi-Document Support: Automatically segments and validates multiple resource documents declared within a single YAML file.
How to use the tool?
- Paste Manifest YAML: Enter, upload, or paste your Kubernetes YAML configuration (single or multi-document) into the editor or click Sample.
- Real-Time Validation: Manifests parse and audit automatically as you type or paste.
- Inspect Diagnostics: Review real-time resource validation cards highlighting compliant specs or missing mandatory fields.
Related Developer Utilities
If you work with Kubernetes manifests, container orchestration, and YAML configurations, explore these complementary tools:
- YAML Syntax Validator: Validate YAML indentation and check line/column syntax errors.
- YAML Formatter: Clean and re-indent messy Kubernetes manifest files.
- YAML to JSON Converter: Convert Kubernetes manifests into JSON payloads.
- YAML Schema Validator: Validate YAML files against Draft-07 / 2020-12 schemas.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/yaml/kubernetes-manifest-validator) to programmatically audit your Kubernetes deployment manifest configurations against standard resource schemas.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object / Array | Multi-document Kubernetes resource configuration YAML string or native parsed object/array (aliases: rawYaml, yaml, data, payload, input, manifest). |
"apiVersion: v1\nkind: Pod\n..." |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/yaml/kubernetes-manifest-validator \
-H "Content-Type: application/json" \
-d '{
"rawText": "apiVersion: v1\nkind: Pod\nmetadata:\n name: nginx\nspec:\n containers:\n - name: nginx\n image: nginx:1.14.2"
}'Python
import requests
url = "https://blueutils.com/api/yaml/kubernetes-manifest-validator"
payload = {
"rawText": "apiVersion: v1\nkind: Pod\nmetadata:\n name: nginx\nspec:\n containers:\n - name: nginx\n image: nginx:1.14.2"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"rawText": "apiVersion: v1\\nkind: Pod\\nmetadata:\\n name: nginx\\nspec:\\n containers:\\n - name: nginx\\n image: nginx:1.14.2"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/yaml/kubernetes-manifest-validator"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether all parsed documents comply with schemas. | true |
documentsCount |
Number | Count of successfully parsed resource document blocks. | 1 |
results |
Array | Summary validation results for each parsed resource document. | [{"documentIndex":1,"kind":"Pod"}] |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"documentsCount": 1,
"results": [
{
"documentIndex": 1,
"apiVersion": "v1",
"kind": "Pod",
"name": "nginx",
"isValid": true,
"errors": []
}
]
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"documentsCount": 1,
"results": [
{
"documentIndex": 1,
"apiVersion": "v1",
"kind": "Pod",
"name": "nginx",
"isValid": false,
"errors": [
"Container at index 0 is missing its \"image\" reference."
]
}
]
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to validate Kubernetes manifests?
Incorporating this validation check during pre-commit hooks, CI/CD runners, or deployment pipelines provides critical advantages:
- Rapid Script Validation: Catches missing container images or broken selector labels before applying configurations to production Kubernetes clusters.
- Optimized Token Efficiency for AI Agents: LLMs frequently emit incomplete Kubernetes specs. Calling the validator flags structural schema gaps deterministically with minimal token usage.
- Deterministic Accuracy Without Hallucinations: Ensures 100% schema compliance against core Kubernetes resource specifications without cluster dependencies.
Native Usage
How to validate Kubernetes manifests locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Validate manifest syntax using kubectl dry-run in PowerShell
kubectl apply --dry-run=client -f .\deployment.yamlLinux / Unix (Bash)
# Validate local file specifications using kubeval or kubeconform in Linux
kubeval deployment.yamlPython
Using Python yaml:
import yaml
with open('deployment.yaml', 'r') as f:
docs = list(yaml.safe_load_all(f))
for i, doc in enumerate(docs):
assert 'apiVersion' in doc and 'kind' in doc and 'metadata' in doc, f"Doc {i+1} missing root fields"
print(f"Doc {i+1} ({doc['kind']}: {doc['metadata'].get('name')}) is syntactically valid.")Java
Using Java and SnakeYAML:
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
import java.util.Map;
public class K8sValidatorExample {
public static void main(String[] args) throws Exception {
Yaml yaml = new Yaml();
try (FileInputStream in = new FileInputStream("deployment.yaml")) {
for (Object data : yaml.loadAll(in)) {
Map<?, ?> doc = (Map<?, ?>) data;
if (doc.containsKey("apiVersion") && doc.containsKey("kind")) {
System.out.println("Valid K8s Resource: " + doc.get("kind"));
}
}
}
}
}