mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
gce/kube-down: Parallelize IGM deletion, batch more
Batch up to 200 instance / route deletions, handle IGM deletion in parallel.
This commit is contained in:
parent
94f8c9fbc5
commit
2d77dc639b
@ -936,6 +936,8 @@ function check-cluster() {
|
|||||||
# API calls and exceeding API quota. It is important to bring down the instances before bringing
|
# API calls and exceeding API quota. It is important to bring down the instances before bringing
|
||||||
# down the firewall rules and routes.
|
# down the firewall rules and routes.
|
||||||
function kube-down {
|
function kube-down {
|
||||||
|
local -r batch=200
|
||||||
|
|
||||||
detect-project
|
detect-project
|
||||||
detect-node-names # For INSTANCE_GROUPS
|
detect-node-names # For INSTANCE_GROUPS
|
||||||
|
|
||||||
@ -964,10 +966,15 @@ function kube-down {
|
|||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--quiet \
|
--quiet \
|
||||||
--zone "${ZONE}" \
|
--zone "${ZONE}" \
|
||||||
"${group}"
|
"${group}" &
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Wait for last batch of jobs
|
||||||
|
kube::util::wait-for-jobs || {
|
||||||
|
echo -e "Failed to delete instance group(s)." >&2
|
||||||
|
}
|
||||||
|
|
||||||
if gcloud compute instance-templates describe --project "${PROJECT}" "${template}" &>/dev/null; then
|
if gcloud compute instance-templates describe --project "${PROJECT}" "${template}" &>/dev/null; then
|
||||||
gcloud compute instance-templates delete \
|
gcloud compute instance-templates delete \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
@ -1013,14 +1020,14 @@ function kube-down {
|
|||||||
--format='value(name)') )
|
--format='value(name)') )
|
||||||
# If any minions are running, delete them in batches.
|
# If any minions are running, delete them in batches.
|
||||||
while (( "${#minions[@]}" > 0 )); do
|
while (( "${#minions[@]}" > 0 )); do
|
||||||
echo Deleting nodes "${minions[*]::10}"
|
echo Deleting nodes "${minions[*]::${batch}}"
|
||||||
gcloud compute instances delete \
|
gcloud compute instances delete \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--quiet \
|
--quiet \
|
||||||
--delete-disks boot \
|
--delete-disks boot \
|
||||||
--zone "${ZONE}" \
|
--zone "${ZONE}" \
|
||||||
"${minions[@]::10}"
|
"${minions[@]::${batch}}"
|
||||||
minions=( "${minions[@]:10}" )
|
minions=( "${minions[@]:${batch}}" )
|
||||||
done
|
done
|
||||||
|
|
||||||
# Delete firewall rule for the master.
|
# Delete firewall rule for the master.
|
||||||
@ -1051,12 +1058,12 @@ function kube-down {
|
|||||||
--regexp "${TRUNCATED_PREFIX}-.{8}-.{4}-.{4}-.{4}-.{12}" \
|
--regexp "${TRUNCATED_PREFIX}-.{8}-.{4}-.{4}-.{4}-.{12}" \
|
||||||
--format='value(name)') )
|
--format='value(name)') )
|
||||||
while (( "${#routes[@]}" > 0 )); do
|
while (( "${#routes[@]}" > 0 )); do
|
||||||
echo Deleting routes "${routes[*]::10}"
|
echo Deleting routes "${routes[*]::${batch}}"
|
||||||
gcloud compute routes delete \
|
gcloud compute routes delete \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--quiet \
|
--quiet \
|
||||||
"${routes[@]::10}"
|
"${routes[@]::${batch}}"
|
||||||
routes=( "${routes[@]:10}" )
|
routes=( "${routes[@]:${batch}}" )
|
||||||
done
|
done
|
||||||
|
|
||||||
# Delete the master's reserved IP
|
# Delete the master's reserved IP
|
||||||
|
Loading…
Reference in New Issue
Block a user