Complete Reference with Copy-Paste Examples
Part of The Direct Path to Linux Ubuntu
— free for all students and developers.
Kubernetes, Helm, Docker Compose, Ansible, GitHub Actions, GitLab CI — every major DevOps tool uses YAML for configuration.
YAML supports comments, multiline strings, and anchors for reuse — making complex configurations readable and maintainable.
All valid JSON is valid YAML — you can migrate gradually and use JSON-style flow syntax where needed.
Every Kubernetes resource — Deployments, Services, ConfigMaps, Ingress — is defined in YAML. It's the language of cloud-native.
Run a YAML program:
# Parse YAML (Python): pip install pyyaml # install PyYAML python3 yaml_demo.py # run script # Command-line YAML processing with yq: snap install yq # Ubuntu/Debian brew install yq # macOS yq '.' config.yaml # pretty-print yq '.database.host' config.yaml # extract field yq -o json '.' config.yaml # convert to JSON yq -P '.' config.json # convert JSON to YAML # Validate YAML: python3 -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]))" file.yaml yamllint file.yaml # install: pip install yamllint