Manifest Missing Required Fields
Detect when a Kubernetes manifest is missing the three required top-level fields: apiVersion, kind, and metadata.name. These fields are mandatory for every resource.
Structure
Detailed Explanation
The Three Required Fields
Every Kubernetes resource must have three top-level fields: apiVersion, kind, and metadata.name. Without these, the Kubernetes API server will reject the manifest outright.
Example with Missing Fields
metadata:
labels:
app: broken
spec:
replicas: 1
template:
spec:
containers:
- name: app
image: myapp:1.0
What the Validator Flags
- Error: Missing required field 'apiVersion'
- Error: Missing required field 'kind'
Required Field Reference
| Field | Purpose | Example |
|---|---|---|
apiVersion |
Identifies the API group and version | apps/v1, v1, batch/v1 |
kind |
Specifies the resource type | Deployment, Service, ConfigMap |
metadata.name |
Unique identifier within namespace | my-app, redis-primary |
Common Causes of Missing Fields
- Copy-paste errors: Accidentally cutting off the top of a manifest
- Template rendering issues: Helm or Kustomize not injecting values
- YAML merge problems: Incorrect YAML anchors or overrides
- Documentation snippets: Incomplete examples from tutorials
Naming Conventions
The metadata.name field must follow DNS subdomain naming rules:
- Lowercase alphanumeric characters, hyphens, and dots
- Maximum 253 characters
- Must start and end with an alphanumeric character
These constraints apply to most resource types. Some resources (like ConfigMaps used as environment sources) have slightly different rules.
Use Case
Catching incomplete manifests before they reach the CI/CD pipeline. Useful when building manifests from templates or assembling multi-resource configurations.