Skip to content

Commit 3e105d2

Browse files
committed
add helm-uninstall task to remove all charts from cluster
1 parent 28d1202 commit 3e105d2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

applications/wg-easy/Taskfile.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ tasks:
223223
- setup-kubeconfig
224224
- cluster-ports-expose
225225

226+
helm-uninstall:
227+
desc: Uninstall all charts using helm uninstall
228+
silent: false
229+
cmds:
230+
- echo "Uninstalling all charts via helm"
231+
- |
232+
# Get cluster ID
233+
CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
234+
if [ -z "$CLUSTER_ID" ]; then
235+
echo "Error: Could not find cluster with name {{.CLUSTER_NAME}}"
236+
exit 1
237+
fi
238+
239+
# Get the list of installed releases and uninstall them
240+
KUBECONFIG={{.KUBECONFIG_FILE}} helm list --all-namespaces -o json | jq -r '.[] | .name + " -n " + .namespace' | while read release; do
241+
echo "Uninstalling helm release: $release"
242+
KUBECONFIG={{.KUBECONFIG_FILE}} helm uninstall $release
243+
done
244+
- echo "All charts uninstalled!"
245+
deps:
246+
- setup-kubeconfig
247+
226248
cluster-delete:
227249
desc: Delete all test clusters with matching name and clean up kubeconfig
228250
silent: false

0 commit comments

Comments
 (0)