Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WF to delete individual app by name #77

Merged
merged 3 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions templates/argo-additional-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ rules:
- create
- delete
- list
- apiGroups:
- "apps"
resources:
- deployments
verbs:
- get
- watch
- delete
- list
- apiGroups:
- apiextensions.k8s.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ metadata:
name: delete-apps
namespace: argo
spec:
entrypoint: DeleteAppsByLabel
arguments:
parameters:
# Filter to filter argocd apps (E.g., "app=lma")
# This is only for 'DeleteAppsByLabel' template
- name: filter
value: ""
templates:
- name: DeleteAppsByLabel
activeDeadlineSeconds: 900
container:
name: 'delete-apps'
name: 'delete-apps-by-label'
image: docker.io/sktcloud/argocd-cli:v2.2.5
imagePullPolicy: IfNotPresent
command:
Expand Down Expand Up @@ -81,3 +83,43 @@ spec:
env:
- name: FILTER
value: "{{workflow.parameters.filter}}"

- name: DeleteAppsByName
activeDeadlineSeconds: 900
inputs:
parameters:
- name: app_name
container:
name: 'delete-apps-by-name'
image: docker.io/sktcloud/argocd-cli:v2.2.5
imagePullPolicy: IfNotPresent
command:
- /bin/bash
- -c
- |
# log into Argo CD server
./argocd login $ARGO_SERVER --plaintext --insecure --username $ARGO_USERNAME \
--password $ARGO_PASSWORD

# Pre-check: validate if the app exists
if ! (./argocd app list | grep $APP); then
echo "No such app: $APP. Skipping app removal.."
exit 1
fi

echo "Found app '$APP'. Start deleting it.."
./argocd app delete $APP --cascade -y

while (./argocd app list | grep $APP )
do
echo "Waiting 20 secs for the app to be deleted.."
sleep 20
done

echo "App '$APP' have been deleted!"
envFrom:
- secretRef:
name: "decapod-argocd-config"
env:
- name: APP
value: "{{inputs.parameters.app_name}}"