yq
15 commands
15 shown
Read YAML field
Extract a value from a YAML file
yq '.spec.replicas' deployment.yaml
Set YAML field
In-place update of a YAML field
yq -i '.spec.replicas = 3' deployment.yaml
Convert YAML to JSON
Output YAML as JSON for jq processing
yq -o=json deployment.yaml
Merge YAML files
Deep-merge a base YAML with an override file
yq '. *= load("override.yaml")' base.yaml
Multi-document YAML to array
Split a multi-document YAML into a JSON array
yq -s '.' multi.yaml | yq -o=json
Read a field value
Extract a single field from YAML
yq '.spec.replicas' deployment.yaml
Set a field value in-place
Modify YAML file in-place with yq v4
yq -i '.spec.replicas = 3' deployment.yaml
Add array element
Append an env var to the first container
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yaml
Delete a key
Remove a specific annotation from YAML
yq -i 'del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' resource.yaml
Merge two YAML files
Deep-merge two YAML documents
yq eval-all 'select(fileIndex==0) * select(fileIndex==1)' base.yaml override.yaml
Convert YAML to JSON
Output YAML document as JSON
yq -o=json '.' config.yaml
Convert JSON to YAML
Pretty-print JSON as YAML
cat config.json | yq -P '.'
Filter array items by condition
Select only Running pods from a list
yq '.items[] | select(.status.phase == "Running")' pods.yaml
Update image tag across manifests
Targeted image update for a named container
yq -i '(.spec.template.spec.containers[] | select(.name == "app") | .image) = "myapp:v2.0.0"' deployment.yaml
Process multiple files at once
Extract metadata.name from all YAML files in a directory
yq '.metadata.name' manifests/*.yaml
no commands match