Add array element
Append an 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 a specific annotation from YAML
-
yq eval-all 'select(fileIndex==0) * select(fileIndex==1)' base.yaml override.yamlDeep-merge two YAML documents
-
yq -o=json '.' config.yamlOutput YAML document as JSON
-
cat config.json | yq -P '.'Pretty-print JSON as YAML
-
yq '.items[] | select(.status.phase == "Running")' pods.yamlSelect only Running pods from a list