Skip to content

Instantly share code, notes, and snippets.

@carlosedp
Last active November 27, 2023 09:47
Show Gist options
  • Save carlosedp/b1e3e784bf4c68835ef86f6e4a9487e7 to your computer and use it in GitHub Desktop.
Save carlosedp/b1e3e784bf4c68835ef86f6e4a9487e7 to your computer and use it in GitHub Desktop.
Openshift Network Sizing

Openshift Network Sizing

Parameters on inventory [OSE3:vars]

osm_host_subnet_length

This variable specifies the size of the per host subnet allocated for pod IPs by OpenShift Container Platform SDN. Defaults to 9 which means that a subnet of size /23 is allocated to each host; for example, given the default 10.128.0.0/14 cluster network, this will allocate 10.128.0.0/23, 10.128.2.0/23, 10.128.4.0/23, and so on. This cannot be re-configured after deployment.

osm_cluster_network_cidr

This variable overrides the SDN cluster network CIDR block. This is the network from which pod IPs are assigned. Specify a private block that does not conflict with existing network blocks in your infrastructure to which pods, nodes, or the master might require access. Defaults to 10.128.0.0/14 and cannot be arbitrarily re-configured after deployment, although certain changes to it can be made in the SDN master configuration.

openshift_portal_net

This variable configures the subnet in which services will be created in the OpenShift Container Platform SDN. Specify a private block that does not conflict with any existing network blocks in your infrastructure to which pods, nodes, or the master might require access to, or the installation will fail. Defaults to 172.30.0.0/16, and cannot be re-configured after deployment. If changing from the default, avoid 172.17.0.0/16, which the docker0 network bridge uses by default, or modify the docker0 network.

Ex:

[OSE3:vars]
osm_cluster_network_cidr=10.128.0.0/14
openshift_portal_net=10.172.0.0/16
osm_host_subnet_length=9

Formula

Max pods per node = (2 ^ osm_host_subnet_length) - 2

Max IPs available for PODs = 2 ^ (32 - osm_cluster_network_cidr) - 2

Max amount of nodes = (2 ^ (32 - osm_cluster_network_cidr) - 2) / ((2 ^ osm_host_subnet_length) - 2 )

Examples

On Python (using default values):

osm_cluster_network_cidr = 14
osm_host_subnet_length = 9
maxnodes = (pow(2,(32-osm_cluster_network_cidr))-2) / (pow(2,osm_host_subnet_length)-2)
print(maxnodes)

Using /14 for cluster and /9 for nodes (510 pods/node):

>>> (pow(2,(32-14))-2) / (pow(2,9)-2)
514

Using /14 for cluster and /8 for nodes (254 pods/node):

>>> (pow(2,(32-14))-2) / (pow(2,8)-2)
1032

Using /16 for cluster and /8 for nodes (254 pods/node):

>>> (pow(2,(32-16))-2) / (pow(2,8)-2)
258

Using /16 for cluster and /9 for nodes (510 pods/node):

>>> (pow(2,(32-16))-2) / (pow(2,9)-2)
128

References:

@palonsoro
Copy link

Many of the names are old (even for 3.11). They should be replaced for the more current equivalent terms (pod network, cluster network...)

But what is more important: Max nodes number calculation is wrong.

The right formula would be: 2^(32-host_subnet_length-pod_network_prefix_length).

In the example, this would be: 2^(32-14-9)=2^9=512

You can double-check this easily with the ipcalc command available in Fedora, like this:

$ ipcalc -S 23 10.128.0.0/14

This one will show you the networks. If you just want to count them, try

$ ipcalc -S 23 10.128.0.0/14 --no-decorate | wc -l
512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment