diff --git a/cluster/gke/config-common.sh b/cluster/gke/config-common.sh index bc5e078dc21c2..279b65a21b632 100644 --- a/cluster/gke/config-common.sh +++ b/cluster/gke/config-common.sh @@ -25,6 +25,7 @@ CLUSTER_API_VERSION="${CLUSTER_API_VERSION:-}" # TODO(mbforbes): Actually plumb this through; this currently only works # because we use the 'default' network by default. NETWORK="${NETWORK:-default}" +NETWORK_RANGE="${NETWORK_RANGE:-10.240.0.0/16}" GCLOUD="${GCLOUD:-gcloud}" GCLOUD_CONFIG_DIR="${GCLOUD_CONFIG_DIR:-${HOME}/.config/gcloud/kubernetes}" ENABLE_CLUSTER_DNS=false diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index 123e8a6a463d7..ab99b6d554df9 100644 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -87,6 +87,14 @@ function verify-prereqs() { function kube-up() { echo "... in kube-up()" >&2 detect-project >&2 + + # Make the specified network if we need to. + if ! gcloud compute networks describe "${NETWORK}" &>/dev/null; then + echo "Creating new network: ${NETWORK}" >&2 + gcloud compute networks create "${NETWORK}" --range "${NETWORK_RANGE}" + fi + + # Bring up the cluster. "${GCLOUD}" preview container clusters create "${CLUSTER_NAME}" \ --zone="${ZONE}" \ --project="${PROJECT}" \