
CUE Has a Free API: The Language That Validates Your YAML, JSON, and Protobuf
Your Kubernetes YAML has 200 lines. Line 147 has a typo. You won't find it until the deploy fails at 2 AM. CUE finds it at write time. What Is CUE? CUE is a data validation language and configuration system from the creator of Go's template package. It unifies types, values, and constraints into one concept. // Define a constraint (schema) #Deployment: { apiVersion: "apps/v1" kind: "Deployment" metadata: { name: string & =~"^[a-z][a-z0-9-]*$" namespace: string | *"default" } spec: { replicas: int & >=1 & <=100 selector: matchLabels: [string]: string template: spec: containers: [...#Container] } } #Container: { name: string image: string & =~"^[a-z].*:.*$" ports: [...{containerPort: int & >0 & <=65535}] resources: { limits: {cpu: string; memory: string} requests: {cpu: string; memory: string} } } // Use it — CUE validates automatically myApp: #Deployment & { metadata: name: "my-app" spec: { replicas: 3 selector: matchLabels: app: "my-app" template: spec: containers: [{ name: "app" image
Continue reading on Dev.to DevOps
Opens in a new tab


