Skip to content

Instantly share code, notes, and snippets.

@rjchicago
Created April 11, 2023 18:08
Show Gist options
  • Save rjchicago/bf13a77cc8dd9d63a69ef529977a1f15 to your computer and use it in GitHub Desktop.
Save rjchicago/bf13a77cc8dd9d63a69ef529977a1f15 to your computer and use it in GitHub Desktop.
Reset ArgoCD Application Finalizers
# In switching Git repositories, I found you must delete the ArgoCD ApplicationSets and
# Applications in order to allow ArgoCD to recreate. However, deleting the resources can
# hang due to finalizers. Run the below script to reset the ArgoCD Application finalizers:
# get argocd applications by name, one per row
APPS=$(kubectl get -n ${NAMESPACE:-argocd} applications.argoproj.io -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{"\n"}{end}')
# loop through and reset each application's finalizers
while read -r APP; do
kubectl patch -n ${NAMESPACE:-argocd} applications.argoproj.io/$APP -p '{"metadata":{"finalizers":[]}}' --type=merge
done <<< $APPS
# verify sync/health status
kubectl get applications.argoproj.io -n argocd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment