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
1c18c326
Unverified
Commit
1c18c326
authored
May 10, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77386 from SataQiu/fix-shellcheck-20190503
Fix shellcheck failures of cluster/gce/upgrade-aliases.sh
parents
aabd8f9b
2ba02316
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
21 deletions
+29
-21
upgrade-aliases.sh
cluster/gce/upgrade-aliases.sh
+29
-20
.shellcheck_failures
hack/.shellcheck_failures
+0
-1
No files found.
cluster/gce/upgrade-aliases.sh
View file @
1c18c326
...
...
@@ -26,7 +26,7 @@ if [[ "${KUBERNETES_PROVIDER:-gce}" != "gce" ]]; then
exit
1
fi
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../..
source
"
${
KUBE_ROOT
}
/hack/lib/util.sh"
source
"
${
KUBE_ROOT
}
/cluster/kube-util.sh"
...
...
@@ -35,8 +35,9 @@ source "${KUBE_ROOT}/cluster/kube-util.sh"
# Assumed vars:
# PROJECT
function
get-k8s-node-routes-count
()
{
local
k8s_node_routes_count
=
$(
gcloud compute routes list
\
--project
=
${
PROJECT
}
--filter
=
'description=k8s-node-route'
\
local
k8s_node_routes_count
k8s_node_routes_count
=
$(
gcloud compute routes list
\
--project
=
"
${
PROJECT
}
"
--filter
=
'description=k8s-node-route'
\
--format
=
'value(name)'
|
wc
-l
)
echo
-n
"
${
k8s_node_routes_count
}
"
}
...
...
@@ -50,11 +51,12 @@ function get-k8s-node-routes-count() {
# Vars set:
# IP_ALIAS_SUBNETWORK
function
detect-k8s-subnetwork
()
{
local
subnetwork_url
=
$(
gcloud compute instances describe
\
${
KUBE_MASTER
}
--project
=
${
PROJECT
}
--zone
=
${
ZONE
}
\
local
subnetwork_url
subnetwork_url
=
$(
gcloud compute instances describe
\
"
${
KUBE_MASTER
}
"
--project
=
"
${
PROJECT
}
"
--zone
=
"
${
ZONE
}
"
\
--format
=
'value(networkInterfaces[0].subnetwork)'
)
if
[[
-n
${
subnetwork_url
}
]]
;
then
IP_ALIAS_SUBNETWORK
=
$
(
echo
${
subnetwork_url
##*/
})
IP_ALIAS_SUBNETWORK
=
$
{
subnetwork_url
##*/
}
fi
}
...
...
@@ -69,21 +71,24 @@ function detect-k8s-subnetwork() {
function
set-allow-subnet-cidr-routes-overlap
()
{
local
allow_subnet_cidr_routes_overlap
allow_subnet_cidr_routes_overlap
=
$(
gcloud compute networks subnets
\
describe
${
IP_ALIAS_SUBNETWORK
}
--project
=
${
PROJECT
}
--region
=
${
REGION
}
\
describe
"
${
IP_ALIAS_SUBNETWORK
}
"
--project
=
"
${
PROJECT
}
"
--region
=
"
${
REGION
}
"
\
--format
=
'value(allowSubnetCidrRoutesOverlap)'
)
local
allow_overlap
=
$1
if
[
${
allow_subnet_cidr_routes_overlap
,,
}
=
${
allow_overlap
}
]
;
then
if
[
"
${
allow_subnet_cidr_routes_overlap
,,
}
"
=
"
${
allow_overlap
}
"
]
;
then
echo
"Subnet
${
IP_ALIAS_SUBNETWORK
}
's allowSubnetCidrRoutesOverlap is already set as
$1
"
return
fi
echo
"Setting subnet
\"
${
IP_ALIAS_SUBNETWORK
}
\"
allowSubnetCidrRoutesOverlap to
$1
"
local
fingerprint
=
$(
gcloud compute networks subnets describe
\
${
IP_ALIAS_SUBNETWORK
}
--project
=
${
PROJECT
}
--region
=
${
REGION
}
\
local
fingerprint
fingerprint
=
$(
gcloud compute networks subnets describe
\
"
${
IP_ALIAS_SUBNETWORK
}
"
--project
=
"
${
PROJECT
}
"
--region
=
"
${
REGION
}
"
\
--format
=
'value(fingerprint)'
)
local
access_token
=
$(
gcloud auth print-access-token
)
local
access_token
access_token
=
$(
gcloud auth print-access-token
)
local
request
=
"{
\"
allowSubnetCidrRoutesOverlap
\"
:
$1
,
\"
fingerprint
\"
:
\"
${
fingerprint
}
\"
}"
local
subnetwork_url
=
"
${
GCE_API_ENDPOINT
}
projects/
${
PROJECT
}
/regions/
${
REGION
}
/subnetworks/
${
IP_ALIAS_SUBNETWORK
}
"
local
subnetwork_url
subnetwork_url
=
"
${
GCE_API_ENDPOINT
}
projects/
${
PROJECT
}
/regions/
${
REGION
}
/subnetworks/
${
IP_ALIAS_SUBNETWORK
}
"
until
curl
-s
--header
"Content-Type: application/json"
--header
"Authorization: Bearer
${
access_token
}
"
\
-X
PATCH
-d
"
${
request
}
"
"
${
subnetwork_url
}
"
--output
/dev/null
;
do
printf
"."
...
...
@@ -100,7 +105,8 @@ function set-allow-subnet-cidr-routes-overlap() {
# CLUSTER_IP_RANGE
# SERVICE_CLUSTER_IP_RANGE
function
add-k8s-subnet-secondary-ranges
()
{
local
secondary_ranges
=
$(
gcloud compute networks subnets describe
"
${
IP_ALIAS_SUBNETWORK
}
"
\
local
secondary_ranges
secondary_ranges
=
$(
gcloud compute networks subnets describe
"
${
IP_ALIAS_SUBNETWORK
}
"
\
--project
=
"
${
PROJECT
}
"
--region
=
"
${
REGION
}
"
\
--format
=
'value(secondaryIpRanges)'
)
if
[[
"
${
secondary_ranges
}
"
=
~
"pods-default"
&&
"
${
secondary_ranges
}
"
=
~
"services-default"
]]
;
then
...
...
@@ -109,8 +115,8 @@ function add-k8s-subnet-secondary-ranges() {
fi
echo
"Adding secondary ranges: pods-default (
${
CLUSTER_IP_RANGE
}
), services-default (
${
SERVICE_CLUSTER_IP_RANGE
}
)"
until
gcloud compute networks subnets update
${
IP_ALIAS_SUBNETWORK
}
\
--project
=
${
PROJECT
}
--region
=
${
REGION
}
\
until
gcloud compute networks subnets update
"
${
IP_ALIAS_SUBNETWORK
}
"
\
--project
=
"
${
PROJECT
}
"
--region
=
"
${
REGION
}
"
\
--add-secondary-ranges
=
"pods-default=
${
CLUSTER_IP_RANGE
}
,services-default=
${
SERVICE_CLUSTER_IP_RANGE
}
"
;
do
printf
"."
sleep
1
...
...
@@ -124,9 +130,12 @@ function add-k8s-subnet-secondary-ranges() {
function
delete-k8s-node-routes
()
{
local
-a
routes
local
-r
batch
=
200
routes
=(
$(
gcloud compute routes list
\
--project
=
${
PROJECT
}
--filter
=
'description=k8s-node-route'
\
--format
=
'value(name)'
)
)
routes
=()
while
IFS
=
$'
\n
'
read
-r
route
;
do
routes+
=(
"
${
route
}
"
)
done
< <
(
gcloud compute routes list
\
--project
=
"
${
PROJECT
}
"
--filter
=
'description=k8s-node-route'
\
--format
=
'value(name)'
)
while
((
"
${#
routes
[@]
}
"
>
0
))
;
do
echo
Deleting k8s node routes
"
${
routes
[*]
::
${
batch
}}
"
gcloud compute routes delete
--project
"
${
PROJECT
}
"
--quiet
"
${
routes
[@]
::
${
batch
}}
"
...
...
@@ -145,7 +154,7 @@ fi
echo
"Found
${
k8s_node_routes_count
}
K8s node routes. Proceeding to upgrade them to IP aliases based connectivity..."
detect-k8s-subnetwork
if
[
-z
${
IP_ALIAS_SUBNETWORK
}
]
;
then
if
[
-z
"
${
IP_ALIAS_SUBNETWORK
}
"
]
;
then
echo
"No k8s cluster subnetwork found. Exiting..."
exit
1
fi
...
...
@@ -165,7 +174,7 @@ export ETCD_IMAGE=3.3.10-0
export
ETCD_VERSION
=
3.3.10
# Upgrade master with updated kube envs
${
KUBE_ROOT
}
/cluster/gce/upgrade.sh
-M
-l
"
${
KUBE_ROOT
}
/cluster/gce/upgrade.sh"
-M
-l
delete-k8s-node-routes
set-allow-subnet-cidr-routes-overlap
false
hack/.shellcheck_failures
View file @
1c18c326
...
...
@@ -10,7 +10,6 @@
./cluster/gce/gci/flexvolume_node_setup.sh
./cluster/gce/gci/health-monitor.sh
./cluster/gce/gci/master-helper.sh
./cluster/gce/upgrade-aliases.sh
./cluster/gce/upgrade.sh
./cluster/gce/util.sh
./cluster/log-dump/log-dump.sh
...
...
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