In my last blog post I deployed an Argo CD app via command line using a YAML file, but what happens when deleting the Argo CD via command line (CLI)?
Kubectl Deletion
I deployed the Argo CD app via a YAML file and kubectl command:
kubectl apply -f geekapp.yaml
And a kubectl can remove the Argo CD app:
kubectl delete -f geekapp.yaml
The above command does remove the app from Argo CD but it does not remove the resources that Argo CD deployed for the app. I asked Argo CD to deploy 2 pods and a load balancer as part of geekapp.yaml, and these can still be viewed via commands such as:
kubectl get pods
Re-applying geekapp.yaml via kubectl and the app shows in Argo CD’s web GUI and confirms that the resources have been deployed for sometime.
kubectl apply -f geekapp.yaml
This is because Argo CD is trying to help protect from accidental resource deletion / data loss. So when the Argo CD app is deleted, the resources stay behind in case they are still required (e.g. you may have wanted to move to a different tool to manage resources).
Finalizers
Kubernetes and Argo CD has options for when you want to delete both the Argo CD app and Kubernetes resources with the kubectl command, Finalizers. I apologise if I slip into the UK English spelling (Finaliser) during this post, if you see that please mentally switch it out with the US English spelling (Finalizer).
A Finalizer removes the Argo CD app and the Kubernetes resources so a note here – be careful if you are using them in a production environment or there may be resource / data loss.
There are two Finalizer options: Foreground and Background. Foreground deletes the resources first, then the Argo CD app. Background deletes Argo CD app whilst Kubernetes deletes the resources in the background. To use a Finalizer it can be added to the metadata for the Argo CD app:
finalizers:
- resources-finalizer.argocd.argoproj.io/foreground
The YAML for deploying the geekapp now looks like the below:
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata: name: geek.app namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io/foregroundspec: project: default destination: namespace: default name: in-cluster source: helm: valueFiles: - values.yaml repoURL: https://github.com/geektechdude/helm-basic-chart path: . syncPolicy: automated: enabled: true
With the YAML adjusted, it needs applying
kubectl apply -f geekapp.yaml
The apply won’t make any noticeable differences but it has now let Argo CD / Kubernetes know that on deletion the foreground Finalizer should be used.
Running a kubectl delete now deletes the Argo CD app and the Kubernetes resources associated with the Argo CD app.
kubectl delete -f geekapp.yaml
Helm List
When deploying charts via Helm, they normally show when running the helm list command.
helm list
But when deploying Helm charts via Argo CD, which is what I’m doing in this and my previous blog post, Helm does not return the installed charts via helm list. This is because Argo CD is managing the resources, and in the background has converted the Helm chart into Kubernetes YAML and is deploying the Kubernetes YAML not the actual Helm chart.



Leave a comment