apiVersion, kind, metadata, spec, status: the shape of every object.
You write the first four. Kubernetes writes status to report what actually exists. The gap between spec and status is what controllers work on.
deployment.yaml
apiVersion: apps/v1 # API group and version kind: Deployment # what type of object metadata: name: checkout namespace: shop labels: {app: checkout} spec: # DESIRED state: you write this replicas: 3 selector: {matchLabels: {app: checkout}} template: # the Pod to create metadata: {labels: {app: checkout}} spec: containers: - {name: app, image: shopwave/checkout:1.4} # status (written by the system): readyReplicas: 2
apiVersion + kind
Pick the exact API, such as apps/v1 + Deployment.
metadata
Identity: name, namespace, labels, annotations.
spec
The desired state. Most changes you make are edits to spec.
status
Observed state, written by controllers. Never apply it.