blob: 71fd263f7fb54742f7ca3c73e6bcefba7a5d8522 [file] [log] [blame]
Matteo Scandolo42f6e572021-01-25 15:11:34 -08001
2def call(List namespaces = ['default'], List excludes = ['docker-registry']) {
3
4 println "Tearing down charts in namespaces: ${namespaces.join(', ')}."
5
6 def exc = excludes.join("|")
7 for(int i = 0;i<namespaces.size();i++) {
8 def n = namespaces[i]
9 sh """
Matteo Scandolobdb2c9d2021-03-18 11:00:29 -070010 for hchart in \$(helm list --all -n ${n} -q | grep -E -v '${exc}');
Matteo Scandolo42f6e572021-01-25 15:11:34 -080011 do
12 echo "Purging chart: \${hchart}"
13 helm delete -n ${n} "\${hchart}"
14 done
15 """
16 }
17
18 println "Waiting for pods to be removed from namespaces: ${namespaces.join(', ')}."
19 for(int i = 0;i<namespaces.size();i++) {
20 def n = namespaces[i]
21 sh """
22 set +x
23 PODS=\$(kubectl get pods -n ${n} --no-headers | wc -l)
24 while [[ \$PODS != 0 ]]; do
25 sleep 5
26 PODS=\$(kubectl get pods -n ${n} --no-headers | wc -l)
27 done
28 """
29 }
30}