diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index 59d532a9cf0..54dfc410f5c 100755 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -104,6 +104,18 @@ function verify-prereqs() { ${sudo_prefix} gcloud ${gcloud_prompt:-} components update || true } +# Validate a kubernetes cluster +function validate-cluster { + # Simply override the NUM_NODES variable if we've spread nodes across multiple + # zones before calling into the generic validate-cluster logic. + local EXPECTED_NUM_NODES="${NUM_NODES}" + for zone in $(echo "${ADDITIONAL_ZONES}" | sed "s/,/ /g") + do + (( EXPECTED_NUM_NODES += NUM_NODES )) + done + NUM_NODES=${EXPECTED_NUM_NODES} bash -c "${KUBE_ROOT}/cluster/validate-cluster.sh" +} + # Instantiate a kubernetes cluster # # Assumed vars: @@ -224,6 +236,9 @@ function detect-nodes() { # Detect minions created in the minion group # +# Note that this will only return the nodes from one of the cluster's instance +# groups, regardless of how many the cluster has. +# # Assumed vars: # none # Vars set: @@ -242,7 +257,10 @@ function detect-node-names { echo "NODE_NAMES=${NODE_NAMES[*]}" } -# Detect instance group name generated by gke +# Detect instance group name generated by gke. +# +# Note that this will only select instance groups in the same zone as the +# cluster, meaning that it won't include all groups in a multi-zone cluster. # # Assumed vars: # GCLOUD @@ -255,7 +273,7 @@ function detect-node-instance-group { echo "... in gke:detect-node-instance-group()" >&2 NODE_INSTANCE_GROUP=$("${GCLOUD}" ${CMD_GROUP:-} container clusters describe \ --project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \ - | grep instanceGroupManagers | cut -d '/' -f 11) + | grep instanceGroupManagers | grep "${ZONE}" | cut -d '/' -f 11) } # SSH to a node by name ($1) and run a command ($2).