Troubleshooting Stuck Application Deletion in Argo CD

When working with Argo CD, you may encounter situations where an application resource becomes stuck during deletion. This can prevent you from reinstalling or reconfiguring your applications. Below are steps to help you resolve this issue.

Steps to Resolve Stuck Deletion

  1. Check Application Configuration: Ensure that your application YAML file has the following configurations:

    spec:
      syncPolicy:
        allowEmpty: true

    This setting allows the application to be deleted even if it has no associated resources.

  2. Remove Finalizers: If the application is still stuck, you may need to remove the metadata.finalizers entry from your application YAML. This can help bypass the finalization process that might be causing the hang-up.

  3. Use kubectl to Force Delete: If the application remains stuck, you can attempt to delete it using the following command:

    kubectl delete application <APPLICATION_NAME> --force --grace-period=0

    Replace <APPLICATION_NAME> with the name of your application. This command forces the deletion without waiting for graceful termination.

  4. Delete the Namespace: If the application resource is still not deleted, you may need to delete the entire namespace:

    kubectl delete namespace argocd --force --grace-period=0

    This will remove all resources within the namespace, including the stuck application.

  5. Reinstall Argo CD: After successfully deleting the application and namespace, you can proceed to reinstall Argo CD using the official installation manifest:

    kubectl delete -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Conclusion

Following these steps should help you resolve issues with stuck application deletions in Argo CD. If problems persist, consider checking the Argo CD logs for more detailed error messages that may provide further insights into the issue.