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
739cb2f5
Commit
739cb2f5
authored
Jul 09, 2015
by
Max Forbes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Robustly cleanup MIG template on GCE teardown
parent
affba42a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
util.sh
cluster/gce/util.sh
+23
-3
No files found.
cluster/gce/util.sh
View file @
739cb2f5
...
...
@@ -769,6 +769,11 @@ function kube-down {
echo
"Bringing down cluster"
set
+e
# Do not stop on error
# Get the name of the managed instance group template before we delete the
# managed instange group. (The name of the managed instnace group template may
# change during a cluster upgrade.)
local
template
=
$(
get-template
"
${
PROJECT
}
"
"
${
ZONE
}
"
"
${
NODE_INSTANCE_PREFIX
}
-group"
)
# The gcloud APIs don't return machine parseable error codes/retry information. Therefore the best we can
# do is parse the output and special case particular responses we are interested in.
if
gcloud preview managed-instance-groups
--project
"
${
PROJECT
}
"
--zone
"
${
ZONE
}
"
describe
"
${
NODE_INSTANCE_PREFIX
}
-group"
&>/dev/null
;
then
...
...
@@ -792,11 +797,11 @@ function kube-down {
fi
fi
if
gcloud compute instance-templates describe
--project
"
${
PROJECT
}
"
"
${
NODE_INSTANCE_PREFIX
}
-template
"
&>/dev/null
;
then
if
gcloud compute instance-templates describe
--project
"
${
PROJECT
}
"
"
${
template
}
"
&>/dev/null
;
then
gcloud compute instance-templates delete
\
--project
"
${
PROJECT
}
"
\
--quiet
\
"
${
NODE_INSTANCE_PREFIX
}
-template
"
"
${
template
}
"
fi
# First delete the master (if it exists).
...
...
@@ -886,6 +891,22 @@ function kube-down {
set
-e
}
# Gets the instance template for the managed instance group with the provided
# project, zone, and group name. It echos the template name so that the function
# output can be used.
#
# $1: project
# $2: zone
# $3: managed instance group name
function
get-template
{
# url is set to https://www.googleapis.com/compute/v1/projects/$1/global/instanceTemplates/<template>
local
url
=
$(
gcloud preview managed-instance-groups
--project
=
"
${
1
}
"
--zone
=
"
${
2
}
"
describe
"
${
3
}
"
|
grep
instanceTemplate
)
# template is set to <template> (the pattern strips off all but last slash)
local
template
=
"
${
url
##*/
}
"
echo
"
${
template
}
"
}
# Checks if there are any present resources related kubernetes cluster.
#
# Assumed vars:
...
...
@@ -894,7 +915,6 @@ function kube-down {
# ZONE
# Vars set:
# KUBE_RESOURCE_FOUND
function
check-resources
{
detect-project
...
...
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