blob: 3dff0ab19bc218e15ea5123d174615326427fb4f [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 """
10 for hchart in \$(helm list -n ${n} -q | grep -E -v '${exc}');
11 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}