mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Auto-calculate CLUSTER_IP_RANGE based on no. of nodes
This commit is contained in:
parent
402e48b072
commit
bacc01f729
@ -84,6 +84,20 @@ function get-node-ip-range {
|
|||||||
echo "${suggested_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
|
if [[ "${FEDERATION:-}" == true ]]; then
|
||||||
NODE_SCOPES="${NODE_SCOPES:-compute-rw,monitoring,logging-write,storage-ro,https://www.googleapis.com/auth/ndev.clouddns.readwrite}"
|
NODE_SCOPES="${NODE_SCOPES:-compute-rw,monitoring,logging-write,storage-ro,https://www.googleapis.com/auth/ndev.clouddns.readwrite}"
|
||||||
else
|
else
|
||||||
|
@ -92,7 +92,7 @@ ETCD_QUORUM_READ="${ENABLE_ETCD_QUORUM_READ:-false}"
|
|||||||
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
||||||
NODE_TAG="${INSTANCE_PREFIX}-minion"
|
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}"
|
MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
|
||||||
|
|
||||||
if [[ "${FEDERATION:-}" == true ]]; then
|
if [[ "${FEDERATION:-}" == true ]]; then
|
||||||
|
@ -93,7 +93,7 @@ ETCD_QUORUM_READ="${ENABLE_ETCD_QUORUM_READ:-false}"
|
|||||||
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
||||||
NODE_TAG="${INSTANCE_PREFIX}-minion"
|
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}"
|
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
|
# 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.
|
# the subnet and is the range used for node instance IPs.
|
||||||
|
@ -301,4 +301,8 @@ func AfterReadingAllFlags(t *TestContextType) {
|
|||||||
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
|
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
|
||||||
t.Host = defaultHost
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user