From 1961e2109874812fb1be696de06e846b047f1f99 Mon Sep 17 00:00:00 2001 From: Shyam Jeedigunta Date: Thu, 5 Apr 2018 17:57:43 +0200 Subject: [PATCH] When using custom network with IP-alias, use the former's subnet for the latter too --- cluster/gce/config-default.sh | 5 +++++ cluster/gce/config-test.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 6c041074430..f60184adf67 100755 --- a/cluster/gce/config-default.sh +++ b/cluster/gce/config-default.sh @@ -288,6 +288,11 @@ if [ ${ENABLE_IP_ALIASES} = true ]; then # Size of ranges allocated to each node. Currently supports only /32 and /24. IP_ALIAS_SIZE=${KUBE_GCE_IP_ALIAS_SIZE:-/24} IP_ALIAS_SUBNETWORK=${KUBE_GCE_IP_ALIAS_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-default} + # If we're using custom network, use the subnet we already create for it as the one for ip-alias. + # Note that this means SUBNETWORK would override KUBE_GCE_IP_ALIAS_SUBNETWORK in case of custom network. + if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then + IP_ALIAS_SUBNETWORK="${SUBNETWORK:-IP_ALIAS_SUBNETWORK}" + fi # Reserve the services IP space to avoid being allocated for other GCP resources. SERVICE_CLUSTER_IP_SUBNETWORK=${KUBE_GCE_SERVICE_CLUSTER_IP_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-services} NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-CloudAllocator} diff --git a/cluster/gce/config-test.sh b/cluster/gce/config-test.sh index 62b77e811eb..04584b43a69 100755 --- a/cluster/gce/config-test.sh +++ b/cluster/gce/config-test.sh @@ -291,6 +291,11 @@ if [ ${ENABLE_IP_ALIASES} = true ]; then # Size of ranges allocated to each node. gcloud current supports only /32 and /24. IP_ALIAS_SIZE=${KUBE_GCE_IP_ALIAS_SIZE:-/24} IP_ALIAS_SUBNETWORK=${KUBE_GCE_IP_ALIAS_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-default} + # If we're using custom network, use the subnet we already create for it as the one for ip-alias. + # Note that this means SUBNETWORK would override KUBE_GCE_IP_ALIAS_SUBNETWORK in case of custom network. + if [[ "${CREATE_CUSTOM_NETWORK}" == true ]]; then + IP_ALIAS_SUBNETWORK="${SUBNETWORK:-IP_ALIAS_SUBNETWORK}" + fi # Reserve the services IP space to avoid being allocated for other GCP resources. SERVICE_CLUSTER_IP_SUBNETWORK=${KUBE_GCE_SERVICE_CLUSTER_IP_SUBNETWORK:-${INSTANCE_PREFIX}-subnet-services} NODE_IPAM_MODE=${KUBE_GCE_NODE_IPAM_MODE:-CloudAllocator}