Add array element yq
Append an env var to the first container
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yaml
more yq
all 15 commands →
Delete a key
yq -i 'del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' resource.yaml
Merge two YAML files
yq eval-all 'select(fileIndex==0) * select(fileIndex==1)' base.yaml override.yaml
Convert YAML to JSON
yq -o=json '.' config.yaml
Convert JSON to YAML
cat config.json | yq -P '.'
Filter array items by condition
yq '.items[] | select(.status.phase == "Running")' pods.yaml