Read a YAML field
Print one value from a YAML file
yq '.spec.replicas' deployment.yaml
More yq commands
-
yq -i '.spec.replicas = 3' deployment.yamlChange a field directly in the file (-i)
-
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yamlAdd the DEBUG env var to the first container
-
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