Skip to content

Conversation

@alexghr
Copy link
Contributor

@alexghr alexghr commented Jan 16, 2026

Use random P2P announce ports so that K8s may schedule pods on the same physical hardware

@alexghr alexghr enabled auto-merge January 16, 2026 12:57
# K8s will use these values to schedule pods on appropriate machines. Using random ports here will allow it to
# colocate pods from different services or even pods from different networks onto the same physical machine
# (so long as the VM has enough resources)
p2p_port_p2p_bootstrap = 40400 + (parseint(substr(md5("${var.NAMESPACE}-p2p-bootstrap"), 0, 4), 16) % 100)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, won't it produce a number between 0 - 100? Does it matter if multiple ports land on the same number?

Copy link
Contributor Author

@alexghr alexghr Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. If two pods conflict on the port then K8s will be forced to schedule the two pods on different VMs. The current behaviour is that all pods use the same port (40400) so no two pods can be scheduled on the same VM

@alexghr alexghr disabled auto-merge January 19, 2026 11:37
@alexghr alexghr enabled auto-merge January 19, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants