Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
de0d59be
Commit
de0d59be
authored
May 12, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8096 from saad-ali/fixTemplateUpDown
Make MIG deletion during GCE kube down blocking, so that subsequent template deletion doesn't fail.
parents
5e11830e
932cdd95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
util.sh
cluster/gce/util.sh
+28
-10
No files found.
cluster/gce/util.sh
View file @
de0d59be
...
@@ -643,16 +643,33 @@ function kube-down {
...
@@ -643,16 +643,33 @@ function kube-down {
detect-project
detect-project
echo
"Bringing down cluster"
echo
"Bringing down cluster"
set
+e
# Do not stop on error
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
delete
\
# The gcloud APIs don't return machine parsable error codes/retry information. Therefore the best we can
# do is parse the output and special case particular responses we are interested in.
deleteCmdOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
NODE_INSTANCE_PREFIX
}
-group"
||
true
"
${
NODE_INSTANCE_PREFIX
}
-group"
)
if
[[
"
$deleteCmdOutput
"
!=
""
]]
;
then
# Managed instance group deletion is done asyncronously, we must wait for it to complete, or subsequent steps fail
deleteCmdOperationId
=
$(
echo
$deleteCmdOutput
|
grep
"Operation:"
|
sed
"s/.*Operation:
\s
//"
|
sed
"s/
\s
.*//"
|
sed
"s/ //g"
)
if
[[
"
$deleteCmdOperationId
"
!=
""
]]
;
then
deleteCmdStatus
=
"PENDING"
while
[[
"
$deleteCmdStatus
"
!=
"DONE"
]]
do
sleep
5
deleteCmdOperationOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
get-operation
$deleteCmdOperationId
)
deleteCmdStatus
=
$(
echo
$deleteCmdOperationOutput
|
grep
-i
"status:"
|
sed
"s/.*status:
\s
//"
|
sed
"s/
\s
.*//"
|
sed
"s/ //g"
)
echo
"Waiting for MIG deletion to complete. Current status: "
$deleteCmdStatus
done
fi
fi
gcloud compute instance-templates delete
\
gcloud compute instance-templates delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
NODE_INSTANCE_PREFIX
}
-template"
||
true
"
${
NODE_INSTANCE_PREFIX
}
-template"
# First delete the master (if it exists).
# First delete the master (if it exists).
gcloud compute instances delete
\
gcloud compute instances delete
\
...
@@ -660,14 +677,14 @@ function kube-down {
...
@@ -660,14 +677,14 @@ function kube-down {
--quiet
\
--quiet
\
--delete-disks
all
\
--delete-disks
all
\
--zone
"
${
ZONE
}
"
\
--zone
"
${
ZONE
}
"
\
"
${
MASTER_NAME
}
"
||
true
"
${
MASTER_NAME
}
"
# Delete the master pd (possibly leaked by kube-up if master create failed)
# Delete the master pd (possibly leaked by kube-up if master create failed)
gcloud compute disks delete
\
gcloud compute disks delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
--zone
"
${
ZONE
}
"
\
--zone
"
${
ZONE
}
"
\
"
${
MASTER_NAME
}
"
-pd
||
true
"
${
MASTER_NAME
}
"
-pd
# Find out what minions are running.
# Find out what minions are running.
local
-a
minions
local
-a
minions
...
@@ -683,7 +700,7 @@ function kube-down {
...
@@ -683,7 +700,7 @@ function kube-down {
--quiet
\
--quiet
\
--delete-disks
boot
\
--delete-disks
boot
\
--zone
"
${
ZONE
}
"
\
--zone
"
${
ZONE
}
"
\
"
${
minions
[@]
::10
}
"
||
true
"
${
minions
[@]
::10
}
"
minions
=(
"
${
minions
[@]
:10
}
"
)
minions
=(
"
${
minions
[@]
:10
}
"
)
done
done
...
@@ -691,13 +708,13 @@ function kube-down {
...
@@ -691,13 +708,13 @@ function kube-down {
gcloud compute firewall-rules delete
\
gcloud compute firewall-rules delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
MASTER_NAME
}
-https"
||
true
"
${
MASTER_NAME
}
-https"
# Delete firewall rule for minions.
# Delete firewall rule for minions.
gcloud compute firewall-rules delete
\
gcloud compute firewall-rules delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
MINION_TAG
}
-all"
||
true
"
${
MINION_TAG
}
-all"
# Delete routes.
# Delete routes.
local
-a
routes
local
-a
routes
...
@@ -709,7 +726,7 @@ function kube-down {
...
@@ -709,7 +726,7 @@ function kube-down {
gcloud compute routes delete
\
gcloud compute routes delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
routes
[@]
::10
}
"
||
true
"
${
routes
[@]
::10
}
"
routes
=(
"
${
routes
[@]
:10
}
"
)
routes
=(
"
${
routes
[@]
:10
}
"
)
done
done
...
@@ -719,10 +736,11 @@ function kube-down {
...
@@ -719,10 +736,11 @@ function kube-down {
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--region
"
${
REGION
}
"
\
--region
"
${
REGION
}
"
\
--quiet
\
--quiet
\
"
${
MASTER_NAME
}
-ip"
||
true
"
${
MASTER_NAME
}
-ip"
export
CONTEXT
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
export
CONTEXT
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
clear-kubeconfig
clear-kubeconfig
set
-e
}
}
# Update a kubernetes cluster with latest source
# Update a kubernetes cluster with latest source
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment