33 lines
859 B
Bash
33 lines
859 B
Bash
|
|
KUBECTL=kubectl
|
||
|
|
ns=kore
|
||
|
|
TSK=copy
|
||
|
|
suffix_tasks="tasks"
|
||
|
|
|
||
|
|
pdid=$($KUBECTL get pods -n $ns | grep $TSK | awk '{print $1}')
|
||
|
|
|
||
|
|
kubectl get configMap -n $ns
|
||
|
|
|
||
|
|
_try() {
|
||
|
|
|
||
|
|
local taskid=""
|
||
|
|
taskid=$(echo "$pdid" | awk -F"-" '{print $NF}')
|
||
|
|
local taskpath=${pdid//-$taskid/}
|
||
|
|
suffix_task=$(echo "$taskpath" | awk -F"-" '{print $NF}')
|
||
|
|
local taskname=""
|
||
|
|
taskname=$(echo "$taskpath" | cut -f1 -d"-")
|
||
|
|
local tasktarget=${taskpath//$taskname-/}
|
||
|
|
echo $tasktarget
|
||
|
|
|
||
|
|
local suffix_task=""
|
||
|
|
for vol in $($KUBECTL get pods -n "$ns" "$pdid" -o jsonpath="{.spec.volumes[*].name}")
|
||
|
|
do
|
||
|
|
[[ "$vol" = "storage"* ]] || [[ "$vol" != "config"* ]] && continue
|
||
|
|
if grep -q "$taskname" <<< "$vol"; then
|
||
|
|
echo $KUBECTL delete configMap -n "$ns" "$vol"
|
||
|
|
else
|
||
|
|
[[ "$vol" = *"-$suffix_tasks" ]] && echo $KUBECTL delete configMap -n "$ns" "$vol"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
}
|
||
|
|
_try
|