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}