From b145beb3daefc4c781ac4e4c9dbf5ac02ae894eb Mon Sep 17 00:00:00 2001 From: Bowei Du Date: Thu, 31 Aug 2017 01:33:17 -0700 Subject: [PATCH] Create a secondary range for the services instead of a subnetwork GCE now supports >1 secondary ranges / subnetwork. --- cluster/gce/util.sh | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index fbb1caf3c24..aa1eff79f39 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -849,7 +849,8 @@ function create-subnetworks() { --network ${NETWORK} \ --region ${REGION} \ --range ${NODE_IP_RANGE} \ - --secondary-range "pods-default=${CLUSTER_IP_RANGE}" + --secondary-range "pods-default=${CLUSTER_IP_RANGE}" \ + --secondary-range "services-default=${SERVICE_CLUSTER_IP_RANGE}" echo "Created subnetwork ${IP_ALIAS_SUBNETWORK}" else if ! echo ${subnet} | grep --quiet secondaryIpRanges ${subnet}; then @@ -857,31 +858,6 @@ function create-subnetworks() { exit 1 fi fi - - # Services subnetwork. - local subnet=$(gcloud beta compute networks subnets describe \ - --project "${PROJECT}" \ - --region ${REGION} \ - ${SERVICE_CLUSTER_IP_SUBNETWORK} 2>/dev/null) - - if [[ -z ${subnet} ]]; then - if [[ ${SERVICE_CLUSTER_IP_SUBNETWORK} != ${INSTANCE_PREFIX}-subnet-services ]]; then - echo "${color_red}Subnetwork ${NETWORK}:${SERVICE_CLUSTER_IP_SUBNETWORK} does not exist${color_norm}" - exit 1 - fi - - echo "Creating subnet for reserving service cluster IPs ${NETWORK}:${SERVICE_CLUSTER_IP_SUBNETWORK}" - gcloud beta compute networks subnets create \ - ${SERVICE_CLUSTER_IP_SUBNETWORK} \ - --description "Automatically generated subnet for ${INSTANCE_PREFIX} cluster. This will be removed on cluster teardown." \ - --project "${PROJECT}" \ - --network ${NETWORK} \ - --region ${REGION} \ - --range ${SERVICE_CLUSTER_IP_RANGE} - echo "Created subnetwork ${SERVICE_CLUSTER_IP_SUBNETWORK}" - else - echo "Subnet ${SERVICE_CLUSTER_IP_SUBNETWORK} already exists" - fi } function delete-firewall-rules() { @@ -934,19 +910,6 @@ function delete-subnetworks() { ${IP_ALIAS_SUBNETWORK} fi fi - - if [[ ${SERVICE_CLUSTER_IP_SUBNETWORK} == ${INSTANCE_PREFIX}-subnet-services ]]; then - echo "Removing auto-created subnet ${NETWORK}:${SERVICE_CLUSTER_IP_SUBNETWORK}" - if [[ -n $(gcloud beta compute networks subnets describe \ - --project "${PROJECT}" \ - --region ${REGION} \ - ${SERVICE_CLUSTER_IP_SUBNETWORK} 2>/dev/null) ]]; then - gcloud --quiet beta compute networks subnets delete \ - --project "${PROJECT}" \ - --region ${REGION} \ - ${SERVICE_CLUSTER_IP_SUBNETWORK} - fi - fi } # Generates SSL certificates for etcd cluster. Uses cfssl program.