Merge YAML files
Deep-merge a base YAML with an override file
yq '. *= load("override.yaml")' base.yaml
More yq commands
-
yq -s '.' multi.yaml | yq -o=jsonSplit a multi-document YAML into a JSON array
-
yq '.spec.replicas' deployment.yamlExtract a single field from YAML
-
yq -i '.spec.replicas = 3' deployment.yamlModify YAML file in-place with yq v4
-
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yamlAppend an env var to the first container
-
yq -i 'del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' resource.yamlRemove a specific annotation from YAML