Start here if manifests look like a wall of colons. This part covers the YAML rules that apply to every Pod, Service, and Deployment in the labs—before we talk about Kubernetes fields.
Pod maps to YAML structure. Parts 2 and 3 cover Kubernetes object anatomy, editing workflows, editors, and troubleshooting.
Kubernetes stores desired state as API objects. You declare that state in files—almost always YAML—then run kubectl apply -f your-file.yaml. The control plane reconciles the cluster to match your spec.
{ } braces; spaces show what belongs to which parent key. That is why a single wrong indent breaks the whole file.| Rule | What to do |
|---|---|
| No tabs | Use the space bar (or editor “convert indentation to spaces”). Tabs cause parser errors. |
| Consistent depth | Use 2 spaces per level—this matches most Kubernetes documentation. |
Lists use - | Each list item starts with - at the correct indent, then properties of that item are indented further. |
| Case-sensitive | kind: Pod is valid; kind: pod is not. |
Strings, numbers, booleans—one value per key.
name: nginx replicas: 3 enabled: true
Quote strings when they look like numbers or you need special characters: version: "1.20".
A key whose value is another set of keys is a mapping. Child keys are indented deeper than the parent.
metadata: name: my-pod labels: app: demo
Items in a list share the same parent key. Each item begins with -.
containers: - name: web image: nginx:1.25 - name: sidecar image: busybox:1.36
- for web and sidecar must align: both are direct children of containers:. Properties like name: and image: are indented one level deeper than -.This mirrors the idea of k8s/labs/basics/apache1.yaml: one Pod, one container, one port.
apiVersion: v1 kind: Pod metadata: name: apache1 labels: mycka: k8slearning spec: containers: - name: mycontainer image: docker.io/httpd ports: - containerPort: 80
apiVersion + kindIdentifies which API endpoint handles the object (v1 for core Pod, apps/v1 for Deployment, etc.).
metadata vs specmetadata is identity (name, labels). spec is what you want running—containers, volumes, and so on.
---
Separate documents with --- on its own line. kubectl apply -f applies each object in order.
apiVersion: v1 kind: Namespace metadata: name: demo --- apiVersion: v1 kind: Pod metadata: name: app namespace: demo spec: containers: - name: app image: nginx:1.25
Continue to Part 2 — Objects, labels, Deployments, Services, and kubectl edit/apply patterns.
Comments and multiline text
Comments
Multiline blocks
|keeps line breaks (common in ConfigMaps).>folds lines into a paragraph.