blob: 6070fca820d11c5e2e2533b5a33ce9070c72fe96 [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
Matteo Scandolo95f3bc12021-06-03 15:25:47 -070025 sleep 5
26 PODS=\$(kubectl get pods -n ${n} --no-headers | wc -l)
Matteo Scandolo42f6e572021-01-25 15:11:34 -080027 done
28 """
29 }
30}