How many addresses are used for Pods on creating routes-based clusters in GKE?

113 Views Asked by At

I am going through the doc on creating routes-based clusters in GKE.

In the Pod address range section, it says the following:

A routes-based cluster has a range of IP addresses that are used for Pods and Services. Even though the range is used for both Pods and Services, it is called the Pod address range. The last /20 of the Pod address range is used for Services. A /20 range has 2^12 = 4096 addresses. So 4096 addresses are used for Services, and the rest of the range is used for Pods.

What does it mean to say "rest of the range is used for Pods?" Just like 4096 addresses are used for Services, then how many addresses are used for pods?

1

There are 1 best solutions below

0
On

The maximum number of nodes, Pods, and Services for a given GKE cluster is determined by the size of the cluster subnet and the size of the Pod address range. You cannot change the Pod address range size after you create a cluster.

image

  • For example, if you set the default maximum number of Pods to 110 and the secondary IP address range for Pods to /21, Kubernetes assigns a/24 CIDR range to nodes on the cluster. This allows a maximum of 2(24-21) = 23 = 8 nodes on the cluster.

Similarly, if you set the default maximum Pods to 8 and the cluster's secondary IP address range for Pods to /21, Kubernetes assigns a /28 CIDR range to nodes. This allows a maximum of 2(28-21) = 27 = 128 nodes on the cluster.

  • By default, GKE allocates a /24 alias IP range (256 addresses) to each node for the Pods running on it. On each node, those 256 alias IP addresses support up to 110 Pods. A /24 range has 28 = 256 addresses. So, based on the above we can get the number of nodes and this number of nodes x 256 addresses = total number of pod addresses.

Suppose you plan to create a 900-node cluster. Then you need 900 x 256 = 230,400 addresses for Pods. Now suppose you have a /14 Pod address range. A /14 range has 2^18 = 262,144 addresses. Subtract the 4096 addresses used for Services, and you get 258,048 pod addresses, which is sufficient for 900 nodes.

For more information refer to these Defaults and limits for range sizes and Configure maximum Pods per node. You can also Refer to this blog by Jayendra's Cloud Certification Blog