Auto-calculate CLUSTER_IP_RANGE based on no. of nodes

This commit is contained in:
Shyam Jeedigunta 2017-08-19 03:00:50 +02:00
parent 402e48b072
commit bacc01f729
4 changed files with 20 additions and 2 deletions

View File

@ -84,6 +84,20 @@ function get-node-ip-range {
echo "${suggested_range}"
}
function get-cluster-ip-range {
local suggested_range="10.100.0.0/14"
if [[ "${NUM_NODES}" -gt 1000 ]]; then
suggested_range="10.100.0.0/13"
fi
if [[ "${NUM_NODES}" -gt 2000 ]]; then
suggested_range="10.100.0.0/12"
fi
if [[ "${NUM_NODES}" -gt 4000 ]]; then
suggested_range="10.100.0.0/11"
fi
echo "${suggested_range}"
}
if [[ "${FEDERATION:-}" == true ]]; then
NODE_SCOPES="${NODE_SCOPES:-compute-rw,monitoring,logging-write,storage-ro,https://www.googleapis.com/auth/ndev.clouddns.readwrite}"
else

View File

@ -92,7 +92,7 @@ ETCD_QUORUM_READ="${ENABLE_ETCD_QUORUM_READ:-false}"
MASTER_TAG="${INSTANCE_PREFIX}-master"
NODE_TAG="${INSTANCE_PREFIX}-minion"
CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-10.244.0.0/14}"
CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-$(get-cluster-ip-range)}"
MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
if [[ "${FEDERATION:-}" == true ]]; then

View File

@ -93,7 +93,7 @@ ETCD_QUORUM_READ="${ENABLE_ETCD_QUORUM_READ:-false}"
MASTER_TAG="${INSTANCE_PREFIX}-master"
NODE_TAG="${INSTANCE_PREFIX}-minion"
CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-10.100.0.0/14}"
CLUSTER_IP_RANGE="${CLUSTER_IP_RANGE:-$(get-cluster-ip-range)}"
MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
# NODE_IP_RANGE is used when ENABLE_IP_ALIASES=true. It is the primary range in
# the subnet and is the range used for node instance IPs.

View File

@ -301,4 +301,8 @@ func AfterReadingAllFlags(t *TestContextType) {
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
t.Host = defaultHost
}
// Reset the cluster IP range flag to CLUSTER_IP_RANGE env var, if defined.
if clusterIPRange := os.Getenv("CLUSTER_IP_RANGE"); clusterIPRange != "" {
t.CloudConfig.ClusterIPRange = clusterIPRange
}
}