Append to an array
Add the DEBUG env var to the first container
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yaml
More yq commands
-
yq -i 'del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' resource.yamlRemove the last-applied-configuration annotation from a manifest
-
yq eval-all 'select(fileIndex==0) * select(fileIndex==1)' base.yaml override.yamlDeep-merge override.yaml into base.yaml and print the result
-
yq -o=json '.' config.yamlPrint a YAML document as JSON
-
cat config.json | yq -P '.'Print JSON as readable YAML (-P)
-
yq '.items[] | select(.status.phase == "Running")' pods.yamlSelect only pods in the Running phase