Set a field value in-place yq
Modify YAML file in-place with yq v4
yq -i '.spec.replicas = 3' deployment.yaml
more yq
all 15 commands →
Add array element
yq -i '.spec.containers[0].env += {"name":"DEBUG","value":"true"}' deployment.yaml
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 '.'