Skip to content

Instantly share code, notes, and snippets.

@haarchri
Last active September 21, 2023 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haarchri/5d84301babe2a921885d933fdc926319 to your computer and use it in GitHub Desktop.
Save haarchri/5d84301babe2a921885d933fdc926319 to your computer and use it in GitHub Desktop.
## get all managed resources
kubectl get managed -l crossplane.io/claim-name=test123 -o yaml >> export.yaml
## use only .items[]
cat export.yaml | yq e -P '.items' >> temp.yaml
## create individual files
yq '.[]' temp.yaml -s '"backup_" + .kind +"_"+ .metadata.name'
## add paused annotation
for file in backup* ; do yq eval '.metadata.annotations += {"crossplane.io/paused": "true"}' -i "$file"; done
## apply all files
kubectl apply --dry-run=client $(ls backup*.yml | awk ' { print " -f " $1 } ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment