Delete a key

Remove a specific annotation from YAML

yq -i 'del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' resource.yaml

tool
yq15 commands
tags
yq

More yq commands

  • yq eval-all 'select(fileIndex==0) * select(fileIndex==1)' base.yaml override.yaml

    Deep-merge two YAML documents

  • yq -o=json '.' config.yaml

    Output YAML document as JSON

  • cat config.json | yq -P '.'

    Pretty-print JSON as YAML

  • yq '.items[] | select(.status.phase == "Running")' pods.yaml

    Select only Running pods from a list

  • yq -i '(.spec.template.spec.containers[] | select(.name == "app") | .image) = "myapp:v2.0.0"' deployment.yaml

    Targeted image update for a named container

all 15 yq commands