opyeb YAMLJSON

A checklist for Kubernetes manifest YAML

2026-11-29 · 2 min read

Kubernetes is strict about types. Quote replicas or a port and the API server rejects the manifest. Check value types before you apply.

Numbers versus strings

replicas, containerPort and terminationGracePeriodSeconds are integers. Values under env are always strings, so write "300" with quotes.

cpu and memory are quantity strings: 100m, 128Mi, with a unit attached.

FieldTypeExample
spec.replicasinteger3
containerPortinteger8080
env[].valuestring"300"
resources.limits.cpuquantity500m
resources.limits.memoryquantity256Mi

selector and labels must agree

spec.selector.matchLabels must be a subset of template.metadata.labels. If they disagree the Deployment is created but never finds its pods.

Do not put a version label into the selector: selectors cannot be changed after creation.

spec:
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
        version: v2   # not in the selector

Probes and termination grace

Without a readinessProbe, traffic can reach a pod that is not ready. Give a livenessProbe an initialDelaySeconds before it starts.

A short terminationGracePeriodSeconds or a preStop hook that returns too early cuts in-flight requests. Thirty seconds or more is a good default.

Questions

Why does replicas: "3" fail?

The API rejects a string where it expects an integer. In YAML, 3 and "3" are different values.

How do I convert a multi-document YAML file?

This tool reads each --- separated document and converts them one at a time with the document selector. It does not merge them into one JSON file.

Sources

Every example here can be pasted into the converter as it is.

Open the converter