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
56c781f4
Commit
56c781f4
authored
Jul 10, 2015
by
Rohit Jnagal
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11018 from mbforbes/gceCleanupTemplate
Robustly cleanup MIG template on GCE teardown
parents
9544837e
739cb2f5
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 @
56c781f4
...
@@ -769,6 +769,11 @@ function kube-down {
...
@@ -769,6 +769,11 @@ function kube-down {
echo
"Bringing down cluster"
echo
"Bringing down cluster"
set
+e
# Do not stop on error
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
# 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.
# 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
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 {
...
@@ -792,11 +797,11 @@ function kube-down {
fi
fi
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
\
gcloud compute instance-templates delete
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--quiet
\
"
${
NODE_INSTANCE_PREFIX
}
-template
"
"
${
template
}
"
fi
fi
# First delete the master (if it exists).
# First delete the master (if it exists).
...
@@ -886,6 +891,22 @@ function kube-down {
...
@@ -886,6 +891,22 @@ function kube-down {
set
-e
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.
# Checks if there are any present resources related kubernetes cluster.
#
#
# Assumed vars:
# Assumed vars:
...
@@ -894,7 +915,6 @@ function kube-down {
...
@@ -894,7 +915,6 @@ function kube-down {
# ZONE
# ZONE
# Vars set:
# Vars set:
# KUBE_RESOURCE_FOUND
# KUBE_RESOURCE_FOUND
function
check-resources
{
function
check-resources
{
detect-project
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