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
697f92a5
Unverified
Commit
697f92a5
authored
Aug 09, 2017
by
Philip Ingrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch away from gcloud deprecated flags in compute resource listings
parent
0d17e9de
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
32 deletions
+31
-32
list-resources.sh
cluster/gce/list-resources.sh
+12
-11
upgrade.sh
cluster/gce/upgrade.sh
+1
-2
util.sh
cluster/gce/util.sh
+14
-15
validate-cluster.sh
cluster/validate-cluster.sh
+2
-2
test-e2e-node.sh
hack/make-rules/test-e2e-node.sh
+1
-1
ingress_utils.go
test/e2e/framework/ingress_utils.go
+1
-1
No files found.
cluster/gce/list-resources.sh
View file @
697f92a5
...
@@ -43,11 +43,12 @@ fi
...
@@ -43,11 +43,12 @@ fi
GREP_REGEX
=
""
GREP_REGEX
=
""
function
gcloud-compute-list
()
{
function
gcloud-compute-list
()
{
local
-r
resource
=
$1
local
-r
resource
=
$1
local
-r
filter
=
${
2
:-}
echo
-e
"
\n\n
[
${
resource
}
]"
echo
-e
"
\n\n
[
${
resource
}
]"
local
attempt
=
1
local
attempt
=
1
local
result
=
""
local
result
=
""
while
true
;
do
while
true
;
do
if
result
=
$(
gcloud compute
${
resource
}
list
--project
=
${
PROJECT
}
${
@
:2
})
;
then
if
result
=
$(
gcloud compute
${
resource
}
list
--project
=
${
PROJECT
}
${
filter
:+--filter
=
"
$filter
"
}
${
@
:3
})
;
then
if
[[
!
-z
"
${
GREP_REGEX
}
"
]]
;
then
if
[[
!
-z
"
${
GREP_REGEX
}
"
]]
;
then
result
=
$(
echo
"
${
result
}
"
|
grep
"
${
GREP_REGEX
}
"
||
true
)
result
=
$(
echo
"
${
result
}
"
|
grep
"
${
GREP_REGEX
}
"
||
true
)
fi
fi
...
@@ -73,21 +74,21 @@ echo "Provider: ${KUBERNETES_PROVIDER:-}"
...
@@ -73,21 +74,21 @@ echo "Provider: ${KUBERNETES_PROVIDER:-}"
# List resources related to instances, filtering by the instance prefix if
# List resources related to instances, filtering by the instance prefix if
# provided.
# provided.
gcloud-compute-list instance-templates
--regexp
=
"
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list instance-templates
"name ~ '
${
INSTANCE_PREFIX
}
.*'
"
gcloud-compute-list instance-groups
${
ZONE
:+
"--zones=
${
ZONE
}
"
}
--regexp
=
"
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list instance-groups
"
${
ZONE
:+
"zone:(
${
ZONE
}
) AND "
}
name ~ '
${
INSTANCE_PREFIX
}
.*'
"
gcloud-compute-list instances
${
ZONE
:+
"--zones=
${
ZONE
}
"
}
--regexp
=
"
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list instances
"
${
ZONE
:+
"zone:(
${
ZONE
}
) AND "
}
name ~ '
${
INSTANCE_PREFIX
}
.*'
"
# List disk resources, filter
y
ing by instance prefix if provided.
# List disk resources, filtering by instance prefix if provided.
gcloud-compute-list disks
${
ZONE
:+
"--zones=
${
ZONE
}
"
}
--regexp
=
"
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list disks
"
${
ZONE
:+
"zone:(
${
ZONE
}
) AND "
}
name ~ '
${
INSTANCE_PREFIX
}
.*'
"
# List network resources. We include names starting with "a", corresponding to
# List network resources. We include names starting with "a", corresponding to
# those that Kubernetes creates.
# those that Kubernetes creates.
gcloud-compute-list addresses
${
REGION
:+
"--regions=
${
REGION
}
"
}
--regexp
=
"a.*|
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list addresses
"
${
REGION
:+
"region=(
${
REGION
}
) AND "
}
name ~ 'a.*|
${
INSTANCE_PREFIX
}
.*'
"
# Match either the header or a line with the specified e2e network.
# Match either the header or a line with the specified e2e network.
# This assumes that the network name is the second field in the output.
# This assumes that the network name is the second field in the output.
GREP_REGEX
=
"^NAME
\|
^[^ ]
\+
[ ]
\+\(
default
\|
${
NETWORK
}
\)
"
GREP_REGEX
=
"^NAME
\|
^[^ ]
\+
[ ]
\+\(
default
\|
${
NETWORK
}
\)
"
gcloud-compute-list routes
--regexp
=
"default.*|
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list routes
"name ~ 'default.*|
${
INSTANCE_PREFIX
}
.*'
"
gcloud-compute-list firewall-rules
--regexp
=
"default.*|k8s-fw.*|
${
INSTANCE_PREFIX
}
.*
"
gcloud-compute-list firewall-rules
"name ~ 'default.*|k8s-fw.*|
${
INSTANCE_PREFIX
}
.*'
"
GREP_REGEX
=
""
GREP_REGEX
=
""
gcloud-compute-list forwarding-rules
${
REGION
:+
"
--regions=
${
REGION
}
"
}
gcloud-compute-list forwarding-rules
${
REGION
:+
"
region=(
${
REGION
}
)
"
}
gcloud-compute-list target-pools
${
REGION
:+
"
--regions=
${
REGION
}
"
}
gcloud-compute-list target-pools
${
REGION
:+
"
region=(
${
REGION
}
)
"
}
cluster/gce/upgrade.sh
View file @
697f92a5
...
@@ -436,8 +436,7 @@ function do-node-upgrade() {
...
@@ -436,8 +436,7 @@ function do-node-upgrade() {
for
group
in
${
INSTANCE_GROUPS
[@]
}
;
do
for
group
in
${
INSTANCE_GROUPS
[@]
}
;
do
old_templates+
=(
$(
gcloud compute instance-groups managed list
\
old_templates+
=(
$(
gcloud compute instance-groups managed list
\
--project
=
"
${
PROJECT
}
"
\
--project
=
"
${
PROJECT
}
"
\
--zones
=
"
${
ZONE
}
"
\
--filter
=
"name ~ '
${
group
}
' AND zone:(
${
ZONE
}
)"
\
--regexp
=
"
${
group
}
"
\
--format
=
'value(instanceTemplate)'
||
true
)
)
--format
=
'value(instanceTemplate)'
||
true
)
)
set_instance_template_out
=
$(
gcloud compute instance-groups managed set-instance-template
"
${
group
}
"
\
set_instance_template_out
=
$(
gcloud compute instance-groups managed set-instance-template
"
${
group
}
"
\
--template
=
"
${
template_name
}
"
\
--template
=
"
${
template_name
}
"
\
...
...
cluster/gce/util.sh
View file @
697f92a5
...
@@ -334,8 +334,8 @@ function detect-node-names() {
...
@@ -334,8 +334,8 @@ function detect-node-names() {
detect-project
detect-project
INSTANCE_GROUPS
=()
INSTANCE_GROUPS
=()
INSTANCE_GROUPS+
=(
$(
gcloud compute instance-groups managed list
\
INSTANCE_GROUPS+
=(
$(
gcloud compute instance-groups managed list
\
--
zones
"
${
ZONE
}
"
--
project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
${
NODE_INSTANCE_PREFIX
}
-.+
"
\
--
filter
"name ~ '
${
NODE_INSTANCE_PREFIX
}
-.+' AND zone:(
${
ZONE
}
)
"
\
--format
=
'value(name)'
||
true
)
)
--format
=
'value(name)'
||
true
)
)
NODE_NAMES
=()
NODE_NAMES
=()
if
[[
-n
"
${
INSTANCE_GROUPS
[@]
:-}
"
]]
;
then
if
[[
-n
"
${
INSTANCE_GROUPS
[@]
:-}
"
]]
;
then
...
@@ -1085,7 +1085,7 @@ function add-replica-to-etcd() {
...
@@ -1085,7 +1085,7 @@ function add-replica-to-etcd() {
function
set-existing-master
()
{
function
set-existing-master
()
{
local
existing_master
=
$(
gcloud compute instances list
\
local
existing_master
=
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
$(
get-replica-name-regexp
)
"
\
--
filter
"name ~ '
$(
get-replica-name-regexp
)
'
"
\
--format
"value(name,zone)"
|
head
-n1
)
--format
"value(name,zone)"
|
head
-n1
)
EXISTING_MASTER_NAME
=
"
$(
echo
"
${
existing_master
}
"
|
cut
-f1
)
"
EXISTING_MASTER_NAME
=
"
$(
echo
"
${
existing_master
}
"
|
cut
-f1
)
"
EXISTING_MASTER_ZONE
=
"
$(
echo
"
${
existing_master
}
"
|
cut
-f2
)
"
EXISTING_MASTER_ZONE
=
"
$(
echo
"
${
existing_master
}
"
|
cut
-f2
)
"
...
@@ -1605,7 +1605,7 @@ function kube-down() {
...
@@ -1605,7 +1605,7 @@ function kube-down() {
# Check if this are any remaining master replicas.
# Check if this are any remaining master replicas.
local
REMAINING_MASTER_COUNT
=
$(
gcloud compute instances list
\
local
REMAINING_MASTER_COUNT
=
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
$(
get-replica-name-regexp
)
"
\
--
filter
=
"name ~ '
$(
get-replica-name-regexp
)
'
"
\
--format
"value(zone)"
|
wc
-l
)
--format
"value(zone)"
|
wc
-l
)
# In the replicated scenario, if there's only a single master left, we should also delete load balancer in front of it.
# In the replicated scenario, if there's only a single master left, we should also delete load balancer in front of it.
...
@@ -1647,8 +1647,8 @@ function kube-down() {
...
@@ -1647,8 +1647,8 @@ function kube-down() {
# Find out what minions are running.
# Find out what minions are running.
local
-a
minions
local
-a
minions
minions
=(
$(
gcloud compute instances list
\
minions
=(
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
--zones
"
${
ZONE
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
${
NODE_INSTANCE_PREFIX
}
-.+
"
\
--
filter
=
"name ~ '
${
NODE_INSTANCE_PREFIX
}
-.+' AND zone:(
${
ZONE
}
)
"
\
--format
=
'value(name)'
)
)
--format
=
'value(name)'
)
)
# If any minions are running, delete them in batches.
# If any minions are running, delete them in batches.
while
((
"
${#
minions
[@]
}
"
>
0
))
;
do
while
((
"
${#
minions
[@]
}
"
>
0
))
;
do
...
@@ -1674,7 +1674,7 @@ function kube-down() {
...
@@ -1674,7 +1674,7 @@ function kube-down() {
# first allows the master to cleanup routes itself.
# first allows the master to cleanup routes itself.
local
TRUNCATED_PREFIX
=
"
${
INSTANCE_PREFIX
:0:26
}
"
local
TRUNCATED_PREFIX
=
"
${
INSTANCE_PREFIX
:0:26
}
"
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
--
regexp
"
${
TRUNCATED_PREFIX
}
-.{8}-.{4}-.{4}-.{4}-.{12}"
\
--
filter
=
"name ~ '
${
TRUNCATED_PREFIX
}
-.{8}-.{4}-.{4}-.{4}-.{12}'"
\
--format
=
'value(name)'
)
)
--format
=
'value(name)'
)
)
while
((
"
${#
routes
[@]
}
"
>
0
))
;
do
while
((
"
${#
routes
[@]
}
"
>
0
))
;
do
echo
Deleting routes
"
${
routes
[*]
::
${
batch
}}
"
echo
Deleting routes
"
${
routes
[*]
::
${
batch
}}
"
...
@@ -1740,8 +1740,7 @@ function kube-down() {
...
@@ -1740,8 +1740,7 @@ function kube-down() {
function
get-replica-name
()
{
function
get-replica-name
()
{
echo
$(
gcloud compute instances list
\
echo
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--zones
"
${
ZONE
}
"
\
--filter
=
"name ~ '
$(
get-replica-name-regexp
)
' AND zone:(
${
ZONE
}
)"
\
--regexp
"
$(
get-replica-name-regexp
)
"
\
--format
"value(name)"
|
head
-n1
)
--format
"value(name)"
|
head
-n1
)
}
}
...
@@ -1755,7 +1754,7 @@ function get-replica-name() {
...
@@ -1755,7 +1754,7 @@ function get-replica-name() {
function
get-all-replica-names
()
{
function
get-all-replica-names
()
{
echo
$(
gcloud compute instances list
\
echo
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
$(
get-replica-name-regexp
)
"
\
--
filter
=
"name ~ '
$(
get-replica-name-regexp
)
'
"
\
--format
"value(name)"
|
tr
"
\n
"
","
|
sed
's/,$//'
)
--format
"value(name)"
|
tr
"
\n
"
","
|
sed
's/,$//'
)
}
}
...
@@ -1767,7 +1766,7 @@ function get-master-replicas-count() {
...
@@ -1767,7 +1766,7 @@ function get-master-replicas-count() {
detect-project
detect-project
local
num_masters
=
$(
gcloud compute instances list
\
local
num_masters
=
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
$(
get-replica-name-regexp
)
"
\
--
filter
=
"name ~ '
$(
get-replica-name-regexp
)
'
"
\
--format
"value(zone)"
|
wc
-l
)
--format
"value(zone)"
|
wc
-l
)
echo
-n
"
${
num_masters
}
"
echo
-n
"
${
num_masters
}
"
}
}
...
@@ -1791,7 +1790,7 @@ function get-replica-name-regexp() {
...
@@ -1791,7 +1790,7 @@ function get-replica-name-regexp() {
function
set-replica-name
()
{
function
set-replica-name
()
{
local
instances
=
$(
gcloud compute instances list
\
local
instances
=
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
$(
get-replica-name-regexp
)
"
\
--
filter
=
"name ~ '
$(
get-replica-name-regexp
)
'
"
\
--format
"value(name)"
)
--format
"value(name)"
)
suffix
=
""
suffix
=
""
...
@@ -1856,8 +1855,8 @@ function check-resources() {
...
@@ -1856,8 +1855,8 @@ function check-resources() {
# Find out what minions are running.
# Find out what minions are running.
local
-a
minions
local
-a
minions
minions
=(
$(
gcloud compute instances list
\
minions
=(
$(
gcloud compute instances list
\
--project
"
${
PROJECT
}
"
--zones
"
${
ZONE
}
"
\
--project
"
${
PROJECT
}
"
\
--
regexp
"
${
NODE_INSTANCE_PREFIX
}
-.+
"
\
--
filter
=
"name ~ '
${
NODE_INSTANCE_PREFIX
}
-.+' AND zone:(
${
ZONE
}
)
"
\
--format
=
'value(name)'
)
)
--format
=
'value(name)'
)
)
if
((
"
${#
minions
[@]
}
"
>
0
))
;
then
if
((
"
${#
minions
[@]
}
"
>
0
))
;
then
KUBE_RESOURCE_FOUND
=
"
${#
minions
[@]
}
matching matching
${
NODE_INSTANCE_PREFIX
}
-.+"
KUBE_RESOURCE_FOUND
=
"
${#
minions
[@]
}
matching matching
${
NODE_INSTANCE_PREFIX
}
-.+"
...
@@ -1876,7 +1875,7 @@ function check-resources() {
...
@@ -1876,7 +1875,7 @@ function check-resources() {
local
-a
routes
local
-a
routes
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
routes
=(
$(
gcloud compute routes list
--project
"
${
PROJECT
}
"
\
--
regexp
"
${
INSTANCE_PREFIX
}
-minion-.{4}
"
--format
=
'value(name)'
)
)
--
filter
=
"name ~ '
${
INSTANCE_PREFIX
}
-minion-.{4}'
"
--format
=
'value(name)'
)
)
if
((
"
${#
routes
[@]
}
"
>
0
))
;
then
if
((
"
${#
routes
[@]
}
"
>
0
))
;
then
KUBE_RESOURCE_FOUND
=
"
${#
routes
[@]
}
routes matching
${
INSTANCE_PREFIX
}
-minion-.{4}"
KUBE_RESOURCE_FOUND
=
"
${#
routes
[@]
}
routes matching
${
INSTANCE_PREFIX
}
-minion-.{4}"
return
1
return
1
...
...
cluster/validate-cluster.sh
View file @
697f92a5
...
@@ -56,8 +56,8 @@ if [[ "${KUBERNETES_PROVIDER:-}" == "gce" ]]; then
...
@@ -56,8 +56,8 @@ if [[ "${KUBERNETES_PROVIDER:-}" == "gce" ]]; then
echo
"Validating gce cluster, MULTIZONE=
${
MULTIZONE
:-}
"
echo
"Validating gce cluster, MULTIZONE=
${
MULTIZONE
:-}
"
# In multizone mode we need to add instances for all nodes in the region.
# In multizone mode we need to add instances for all nodes in the region.
if
[[
"
${
MULTIZONE
:-}
"
==
"true"
]]
;
then
if
[[
"
${
MULTIZONE
:-}
"
==
"true"
]]
;
then
EXPECTED_NUM_NODES
=
$(
gcloud
-q
compute instances list
--project
=
"
${
PROJECT
}
"
--format
=[
no-heading]
--regexp
=
"
${
NODE_INSTANCE_PREFIX
}
.*"
\
EXPECTED_NUM_NODES
=
$(
gcloud
-q
compute instances list
--project
=
"
${
PROJECT
}
"
--format
=[
no-heading]
\
--
zones
=
$(
gcloud
-q
compute zones list
--project
=
"
${
PROJECT
}
"
--filter
=
region
=
${
REGION
}
--format
=
csv[no-heading]
\(
name
\)
|
tr
"
\n
"
","
|
sed
"s/,
$/
/"
)
|
wc
-l
)
--
filter
=
"name ~ '
${
NODE_INSTANCE_PREFIX
}
.*' AND zone:(
$(
gcloud
-q
compute zones list
--project
=
"
${
PROJECT
}
"
--filter
=
region
=
${
REGION
}
--format
=
csv[no-heading]
\(
name
\)
|
tr
"
\n
"
","
|
sed
"s/,
$/
/"
)
)"
|
wc
-l
)
echo
"Computing number of nodes, NODE_INSTANCE_PREFIX=
${
NODE_INSTANCE_PREFIX
}
, REGION=
${
REGION
}
, EXPECTED_NUM_NODES=
${
EXPECTED_NUM_NODES
}
"
echo
"Computing number of nodes, NODE_INSTANCE_PREFIX=
${
NODE_INSTANCE_PREFIX
}
, REGION=
${
REGION
}
, EXPECTED_NUM_NODES=
${
EXPECTED_NUM_NODES
}
"
fi
fi
fi
fi
...
...
hack/make-rules/test-e2e-node.sh
View file @
697f92a5
...
@@ -76,7 +76,7 @@ if [ $remote = true ] ; then
...
@@ -76,7 +76,7 @@ if [ $remote = true ] ; then
if
[[
$hosts
==
""
&&
$images
==
""
&&
$image_config_file
==
""
]]
;
then
if
[[
$hosts
==
""
&&
$images
==
""
&&
$image_config_file
==
""
]]
;
then
image_project
=
${
IMAGE_PROJECT
:-
"cos-cloud"
}
image_project
=
${
IMAGE_PROJECT
:-
"cos-cloud"
}
gci_image
=
$(
gcloud compute images list
--project
$image_project
\
gci_image
=
$(
gcloud compute images list
--project
$image_project
\
--no-standard-images
--
regexp
=
"cos-beta.*
"
--format
=
"table[no-heading](name)"
)
--no-standard-images
--
filter
=
"name ~ 'cos-beta.*'
"
--format
=
"table[no-heading](name)"
)
images
=
$gci_image
images
=
$gci_image
metadata
=
"user-data<
${
KUBE_ROOT
}
/test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
metadata
=
"user-data<
${
KUBE_ROOT
}
/test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
fi
fi
...
...
test/e2e/framework/ingress_utils.go
View file @
697f92a5
...
@@ -763,7 +763,7 @@ func gcloudComputeResourceList(resource, regex, project string, out interface{})
...
@@ -763,7 +763,7 @@ func gcloudComputeResourceList(resource, regex, project string, out interface{})
// so we only look at stdout.
// so we only look at stdout.
command
:=
[]
string
{
command
:=
[]
string
{
"compute"
,
resource
,
"list"
,
"compute"
,
resource
,
"list"
,
fmt
.
Sprintf
(
"--
regexp=%q
"
,
regex
),
fmt
.
Sprintf
(
"--
filter='name ~
\"
%q
\"
'
"
,
regex
),
fmt
.
Sprintf
(
"--project=%v"
,
project
),
fmt
.
Sprintf
(
"--project=%v"
,
project
),
"-q"
,
"--format=json"
,
"-q"
,
"--format=json"
,
}
}
...
...
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