programming#yaml#config
YAML Explained with Examples
YAML is everywhere in DevOps (Docker Compose, Kubernetes, GitHub Actions). Learn its 6 rules and you're done.
YAML in 10 Minutes
YAML is a human-friendly data format — like JSON but with less punctuation.
The 6 rules
- Indentation matters — 2 spaces per level. Never use tabs.
key: valueis a mapping.- itemis a list item.- Strings usually don't need quotes.
#starts a comment.---separates multiple documents in one file.
A working example (Kubernetes-ish)
apiVersion: v1
kind: Pod
metadata:
name: web
labels:
app: nginx
tier: frontend
spec:
containers:
- name: nginx
image: nginx:1.27
ports:
- containerPort: 80
env:
- name: LOG_LEVEL
value: info
Tricky parts
- Strings that look like booleans or numbers can bite you:
version: 3.10 # this is 3.1 (a float!) Use "3.10" as string. release: yes # this is boolean true (weird YAML 1.1) Use "yes". - Anchors (advanced) let you reuse blocks:
defaults: &defaults timeout: 30 retries: 3 api: <<: *defaults endpoint: /api
Real-world example
Docker Compose, GitHub Actions, Ansible, Kubernetes, Helm — you'll write YAML every single day. Install a YAML linter in your editor and you'll never miss an indent.
Keep reading
You may also like
programming
Kafka Beyond Basics: Consumer Groups, Replication, Ordering
The three intermediate concepts that turn Kafka from a toy into a production tool.
Read
programming
Python Async: A Practical Guide
asyncio, event loops and when NOT to use async.
Read
programming
React 19 useOptimistic Explained
The new hook that makes optimistic UI trivial — with a working example.
Read
Discussion (0)
No comments yet. Be the first to weigh in.