Skip to content

Instantly share code, notes, and snippets.

@janeczku
Created February 13, 2024 11:50
Show Gist options
  • Save janeczku/697d3012fa67e2abafbaf0346999f03b to your computer and use it in GitHub Desktop.
Save janeczku/697d3012fa67e2abafbaf0346999f03b to your computer and use it in GitHub Desktop.
Batch delete finalizers Kubernetes
#!bin/bash
N=20
task(){
kubectl patch -n hobbyfarm instances.ec2.cattle.io $1 \
--type json \
--patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
}
RESOURCES=$(kubectl -n hobbyfarm get instances.ec2.cattle.io --no-headers -o custom-columns=":metadata.name")
for n in $RESOURCES
do
((i=i%N)); ((i++==0)) && wait
task "$n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment