Skip to content

Commit 15b7995

Browse files
feat: added support for runtime uninstallation
* Added annotation for the argocd controller application and app proxy deployment to prevent deletion mid-uninstall * Refactored the resource-cleanup hook to delete codefresh and git integration secrets and to remove the finalizers from the runtime applications.
1 parent 41b9ff5 commit 15b7995

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

charts/gitops-runtime/templates/_components/cap-app-proxy/_deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: {{ include "cap-app-proxy.fullname" . }}
6+
annotations:
7+
argocd.argoproj.io/sync-options: Delete=false
68
labels:
79
{{- include "cap-app-proxy.labels" . | nindent 4 }}
810
spec:

charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,22 @@ spec:
2020
command: ["sh", "-c"]
2121
args:
2222
- |
23-
kubectl patch EventBus $(kubectl get eventbus -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \
24-
kubectl patch Eventsource $(kubectl get EventSource -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \
25-
kubectl patch Sensor $(kubectl get Sensor -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge ;
26-
return 0
23+
set -e
24+
25+
echo "[cleanup] Namespace: {{ .Release.Namespace }}"
26+
27+
echo "[cleanup] Patching internal Argo CD Applications finalizers..."
28+
kubectl get applications -n {{ .Release.Namespace }} -l codefresh.io/internal=true -o jsonpath='{.items[*].metadata.name}' \
29+
| xargs -r -n1 -I{} sh -c 'echo "[cleanup] Patching application: {}"; kubectl patch application -n {{ .Release.Namespace }} {} -p '\''{"metadata":{"finalizers":null}}'\'' --type=merge' \
30+
|| echo "[cleanup] Failed to patch applications (see errors above)"
31+
32+
echo "[cleanup] Deleting codefresh-token secret..."
33+
kubectl delete secret codefresh-token -n {{ .Release.Namespace }} --ignore-not-found \
34+
|| echo "[cleanup] Failed to delete codefresh-token (see errors above)"
35+
36+
echo "[cleanup] Deleting default git integration secrets..."
37+
kubectl delete secret -n {{ .Release.Namespace }} -l 'io.codefresh.integration-type=git,io.codefresh.integration-name=default' --ignore-not-found \
38+
|| echo "[cleanup] Failed to delete default git integration secrets (see errors above)"
2739
{{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }}
2840
nodeSelector: {{ toYaml . | nindent 8 }}
2941
{{- end }}

charts/gitops-runtime/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ argo-cd:
290290
params:
291291
server.insecure: true
292292
application.namespaces: 'cf-*'
293+
controller:
294+
statefulsetAnnotations:
295+
argocd.argoproj.io/sync-options: "Delete=false"
293296
#-----------------------------------------------------------------------------------------------------------------------
294297
# Argo Events
295298
#-----------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)