Section: Read and query YAML with yq

Read a nested field

bash
bash
yq '.spec.template.spec.containers[0].image' deployment.yaml
Explanation

Excellent for scripts, CI jobs, and quick inspections.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Read and query YAML with yq
Read a list
Print array items from a YAML path.
OpenIn sheetbashsame section
Filter objects in a sequence
Select matching records from a YAML array.
OpenIn sheetbashsame section
Convert YAML to JSON
Transform YAML into JSON for downstream tools.
OpenIn sheetbashsame section
Set an image tag
Update a nested container image value in place.
OpenIn sheetbash2 tag match
Append to a YAML array
Add a value to a sequence in place.
OpenIn sheetbash2 tag match
Delete a key
Remove an unwanted field from YAML.
OpenIn sheetbash2 tag match