Sharing Secondary IP ranges between Google Kubernetes Engine clusters

Problem

We want to have multiple Google Kubernetes Engine clusters in a given Subnet for a Virtual Private Cloud (VPC).

Also, when attempting to create two clusters with the same range, the following error pops up:

Status details Retry budget exhausted (80 attempts): Services range "ALIAS_IP_RANGE_NAME" in network "VPC_NAME", subnetwork "SUBNET_NAME" is already used by another cluster.

Environment

  • Have at least 1 VPC with multiple subnets
  • The permissions to create Google Kubernetes Engine clusters

Solution

Each subnet has a limit of 30 Alias ranges per subnet, therefore it is possible to create multiple Alias ranges in a given subnet and have each Cluster use its own ranges.

Cause

First, we will address why Sharing IP ranges is not recommended:

  • It can add extra noise in the networks
  • The IP range that the subnet is using to assign to Nodes/Pods is now effectively shared among Clusters.
    • This can lead to IP exhaustion since one cluster may use more IPs than another one and therefore leave this second cluster incapable of using more IPs, therefore it being unable to create more nodes.
    • Another point that this is not recommended would be to not need to worry about which IP is where and be sure that a certain IP/range is within a certain cluster.
  • More information can be seen here.
  • A key point to keep in mind is the planning of IP usage by a given Google Kubernetes Engine Cluster. As noted in this document, given this planning and the possible growth of the Google Kubernetes Engine Clusters is why sharing Subnet ranges is not recommended. To avoid coupling, as noted in the second note of the following document.

Related to the error message:

`service ranges` are unique to a given cluster, and they cannot be used by more than one cluster at a time.