Your Kubernetes YAML has 500 lines and a typo in a resource limit crashes production. CUE adds types, constraints, and validation to configuration — catch errors before they deploy.
What Is CUE?
CUE is a data validation language that makes JSON and YAML safe. It combines data definition, validation, code generation, and querying in one tool. Originally designed by a Go team member, it brings the rigor of a type system to configuration files.
Why CUE Is Different
- Types as values: Define schemas and data in the same language
- Validation: Constraint-based validation with clear error messages
- Code generation: Generate Go, JSON Schema, OpenAPI from CUE
- Querying: Query and transform data
- Kubernetes: First-class support for K8s manifests
- Hermetic: Deterministic evaluation, no side effects
- Completely free and open source
Quick Start
Install CUE:
brew install cue-lang/tap/cue
Define a schema with constraints:
// schema.cue
package config
#Service: {
name: string & =~"^[a-z][a-z0-9-]*$"
port: int & >=1 & <=65535
replicas: int & >=1 & <=100
image: string & =~"^[a-z0-9/:-]+$"
resources: {
cpu: string & =~"^[0-9]+m$"
memory: string & =~"^[0-9]+(Mi|Gi)$"
}
env: [...{name: string, value: string}]
}
Use the schema:
// prod.cue
package config
api: #Service & {
name: "api-server"
port: 8080
replicas: 3
image: "myapp/api:v1.2.3"
resources: {
cpu: "500m"
memory: "256Mi"
}
env: [{
name: "DATABASE_URL"
value: "postgres://db:5432/prod"
}]
}
Validate:
# This succeeds
cue vet prod.cue schema.cue
# This fails with clear error:
cue vet bad.cue schema.cue
# api.port: invalid value 99999 (out of bound <=65535)
# api.replicas: invalid value -1 (out of bound >=1)
Export to JSON/YAML:
cue export prod.cue --out json
cue export prod.cue --out yaml
Why Teams Choose CUE
A platform team managed 200+ Kubernetes manifests in YAML. A developer set memory limits to "256" instead of "256Mi", causing OOM kills in production. After migrating to CUE with typed schemas, every manifest is validated before applying. Config-related incidents dropped from monthly to never.
Who Is This For?
- Platform engineers managing Kubernetes configurations
- DevOps teams wanting validated, typed infrastructure configs
- API developers needing schema validation for OpenAPI specs
- Anyone tired of YAML bugs causing production issues
Start Validating
CUE brings type safety to configuration. Define schemas once, validate everywhere.
Need help with configuration management or Kubernetes? I build custom DevOps solutions — reach out to discuss your project.
Found this useful? I publish daily deep-dives into developer tools and APIs. Follow for more.
Top comments (0)