Closed liyanwei93 closed 2 years ago
More thoughts on the long term solution:
The clean up job is essentially very similar to a regular procedure, so that can be nicely modeled as a pipeline task, which can be triggered either manually or automatically. It's easy to encapsulate the clean up shell script into a Tekton task.
The drawback of the above idea is that it is a one-time off job, which can not be used to regularly monitoring the system for an uninstall need. This goes to 2nd option which is a real Kubernetes controller that has reconciliation logic to keep monitoring the system status. As an example, I think maybe the Crossplane provider ansible is a good choice in this case, because it is working as a controller inside a Kubernetes cluster w/ all the native Kubernetes behavior including the reconciliation, as well as the ability to call Ansible roles and playbooks remotely, e.g.: some shell scripts wrapped as Ansible playbook and hosted in a remote git repo. This can nicely handle our case.
Opened a github issue for argoCD at https://github.com/argoproj/argo-cd/issues/9351 to discuss post uninstall
@morningspace @liyanwei93 as we are using helm chart, can we leverage helm chart hooks for uninstall https://helm.sh/docs/topics/charts_hooks/#writing-a-hook ?
Some similar discussions here at: https://github.com/argoproj/argo-cd/issues/7575, as I remember, we couldn't rely on helm hook when combing w/ Argo CD, because there's no such mapping between helm hook and Argo CD sync phase for now, which means the hook will not be triggered when we delete Argo application.
Add delete script task:
Installation CR
deployed successfully, check whether Crossplane has been deployed by common services.check-object-prereqs
job andObject
will be deleted by Argocd when the argocd application is deleted. The left deployment will check the Installation CR for adeletionTimestamp
, and if so will start the delete script.finalizers
to avoid deleting deployments when argocd deleting AIManager namespace. When the script finishes running, it removes these "finalizers"