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
4c19734b
Commit
4c19734b
authored
May 29, 2015
by
goltermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix kube-down errors for GCE
parent
2c20c366
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
50 deletions
+63
-50
util.sh
cluster/gce/util.sh
+63
-50
No files found.
cluster/gce/util.sh
View file @
4c19734b
...
@@ -393,7 +393,7 @@ function create-node-template {
...
@@ -393,7 +393,7 @@ function create-node-template {
# TODO(mbforbes): To make this really robust, we need to parse the output and
# TODO(mbforbes): To make this really robust, we need to parse the output and
# add retries. Just relying on a non-zero exit code doesn't
# add retries. Just relying on a non-zero exit code doesn't
# distinguish an ephemeral failed call from a "not-exists".
# distinguish an ephemeral failed call from a "not-exists".
if
gcloud compute instance-templates describe
"
$1
"
;
then
if
gcloud compute instance-templates describe
"
$1
"
&>/dev/null
;
then
echo
"Instance template
${
1
}
already exists; continuing."
>
&2
echo
"Instance template
${
1
}
already exists; continuing."
>
&2
return
return
fi
fi
...
@@ -726,44 +726,52 @@ function kube-down {
...
@@ -726,44 +726,52 @@ function kube-down {
# The gcloud APIs don't return machine parsable error codes/retry information. Therefore the best we can
# 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.
# do is parse the output and special case particular responses we are interested in.
deleteCmdOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
delete
\
if
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
describe
"
${
NODE_INSTANCE_PREFIX
}
-group"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
deleteCmdOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
"
${
NODE_INSTANCE_PREFIX
}
-group"
)
--quiet
\
if
[[
"
$deleteCmdOutput
"
!=
""
]]
;
then
"
${
NODE_INSTANCE_PREFIX
}
-group"
)
# Managed instance group deletion is done asyncronously, we must wait for it to complete, or subsequent steps fail
if
[[
"
$deleteCmdOutput
"
!=
""
]]
;
then
deleteCmdOperationId
=
$(
echo
$deleteCmdOutput
|
grep
"Operation:"
|
sed
"s/.*Operation:[[:space:]]*
\(
[^[:space:]]*
\)
.*/
\1
/g"
)
# Managed instance group deletion is done asyncronously, we must wait for it to complete, or subsequent steps fail
if
[[
"
$deleteCmdOperationId
"
!=
""
]]
;
then
deleteCmdOperationId
=
$(
echo
$deleteCmdOutput
|
grep
"Operation:"
|
sed
"s/.*Operation:[[:space:]]*
\(
[^[:space:]]*
\)
.*/
\1
/g"
)
deleteCmdStatus
=
"PENDING"
if
[[
"
$deleteCmdOperationId
"
!=
""
]]
;
then
while
[[
"
$deleteCmdStatus
"
!=
"DONE"
]]
deleteCmdStatus
=
"PENDING"
do
while
[[
"
$deleteCmdStatus
"
!=
"DONE"
]]
sleep
5
do
deleteCmdOperationOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
get-operation
$deleteCmdOperationId
)
sleep
5
deleteCmdStatus
=
$(
echo
$deleteCmdOperationOutput
|
grep
-i
"status:"
|
sed
"s/.*status:[[:space:]]*
\(
[^[:space:]]*
\)
.*/
\1
/g"
)
deleteCmdOperationOutput
=
$(
gcloud preview managed-instance-groups
--zone
"
${
ZONE
}
"
get-operation
$deleteCmdOperationId
)
echo
"Waiting for MIG deletion to complete. Current status: "
$deleteCmdStatus
deleteCmdStatus
=
$(
echo
$deleteCmdOperationOutput
|
grep
-i
"status:"
|
sed
"s/.*status:[[:space:]]*
\(
[^[:space:]]*
\)
.*/
\1
/g"
)
done
echo
"Waiting for MIG deletion to complete. Current status: "
$deleteCmdStatus
done
fi
fi
fi
fi
fi
gcloud compute instance-templates delete
\
if
gcloud compute instance-templates describe
"
${
NODE_INSTANCE_PREFIX
}
-template"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute instance-templates delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
"
${
NODE_INSTANCE_PREFIX
}
-template"
--quiet
\
"
${
NODE_INSTANCE_PREFIX
}
-template"
fi
# First delete the master (if it exists).
# First delete the master (if it exists).
gcloud compute instances delete
\
if
gcloud compute instances describe
"
${
MASTER_NAME
}
"
--zone
"
${
ZONE
}
"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute instances delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
--delete-disks
all
\
--quiet
\
--zone
"
${
ZONE
}
"
\
--delete-disks
all
\
"
${
MASTER_NAME
}
"
--zone
"
${
ZONE
}
"
\
"
${
MASTER_NAME
}
"
fi
# 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
\
if
gcloud compute disks describe
"
${
MASTER_NAME
}
"
-pd
--zone
"
${
ZONE
}
"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute disks delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
--zone
"
${
ZONE
}
"
\
--quiet
\
"
${
MASTER_NAME
}
"
-pd
--zone
"
${
ZONE
}
"
\
"
${
MASTER_NAME
}
"
-pd
fi
# Find out what minions are running.
# Find out what minions are running.
local
-a
minions
local
-a
minions
...
@@ -784,24 +792,27 @@ function kube-down {
...
@@ -784,24 +792,27 @@ function kube-down {
done
done
# Delete firewall rule for the master.
# Delete firewall rule for the master.
gcloud compute firewall-rules delete
\
if
gcloud compute firewall-rules describe
"
${
MASTER_NAME
}
-https"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute firewall-rules delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
"
${
MASTER_NAME
}
-https"
--quiet
\
"
${
MASTER_NAME
}
-https"
fi
# Delete firewall rule for minions.
# Delete firewall rule for minions.
gcloud compute firewall-rules delete
\
if
gcloud compute firewall-rules describe
"
${
MINION_TAG
}
-all"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute firewall-rules delete
\
--quiet
\
--project
"
${
PROJECT
}
"
\
"
${
MINION_TAG
}
-all"
--quiet
\
"
${
MINION_TAG
}
-all"
fi
# Delete routes.
# Delete routes.
local
-a
routes
local
-a
routes
# Clean up all routes w/ names like "<cluster-name>-
<node-GUID
>"
# Clean up all routes w/ names like "<cluster-name>-
minion-<4-char-node-identifier
>"
# e.g. "kubernetes-
12345678-90ab-cdef-1234-567890abcdef
"
# e.g. "kubernetes-
minion-2pl1
"
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
--regexp
"
${
INSTANCE_PREFIX
}
-.{8}-.{4}-.{4}-.{4}-.{12}"
|
awk
'NR >= 2 { print $1 }'
)
)
--regexp
"
${
INSTANCE_PREFIX
}
-minion-.{4}"
|
awk
'NR >= 2 { print $1 }'
)
)
routes+
=(
"
${
MASTER_NAME
}
"
)
while
((
"
${#
routes
[@]
}
"
>
0
))
;
do
while
((
"
${#
routes
[@]
}
"
>
0
))
;
do
echo
Deleting routes
"
${
routes
[*]
::10
}
"
echo
Deleting routes
"
${
routes
[*]
::10
}
"
gcloud compute routes delete
\
gcloud compute routes delete
\
...
@@ -813,11 +824,13 @@ function kube-down {
...
@@ -813,11 +824,13 @@ function kube-down {
# Delete the master's reserved IP
# Delete the master's reserved IP
local
REGION
=
${
ZONE
%-*
}
local
REGION
=
${
ZONE
%-*
}
gcloud compute addresses delete
\
if
gcloud compute addresses describe
"
${
MASTER_NAME
}
-ip"
--region
"
${
REGION
}
"
&>/dev/null
;
then
--project
"
${
PROJECT
}
"
\
gcloud compute addresses delete
\
--region
"
${
REGION
}
"
\
--project
"
${
PROJECT
}
"
\
--quiet
\
--region
"
${
REGION
}
"
\
"
${
MASTER_NAME
}
-ip"
--quiet
\
"
${
MASTER_NAME
}
-ip"
fi
export
CONTEXT
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
export
CONTEXT
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
clear-kubeconfig
clear-kubeconfig
...
...
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