Skip to content

Rework podCIDR allocation - #209

Merged
damyan merged 3 commits into
ironcore-dev:mainfrom
mkalcok:pod-cidr-offset
Nov 3, 2026
Merged

damyan merged 3 commits into
ironcore-dev:mainfrom
mkalcok:pod-cidr-offset

Conversation

@mkalcok

@mkalcok mkalcok commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Please don't squash on merge.

After a follow-up request on the original proposal, this PR deals with two related topics across three distinct commits:

  • Replace existing usage of metal.ironcore.dev/loopback-address annotation with metadata.metal.ironcore.dev/prefix
  • Start sourcing podCIDR from metadata.metal.ironcore.dev/prefix, instead of the Server status
  • Implement offset algorithm for podCIDR to avoid collision with node's own internal IP

For ease of review, I recommend taking a look at each commit individually.

@damyan

damyan commented Oct 23, 2026

Copy link
Copy Markdown
Member

Proposal, as discussed:
since we change the arithmetic anyways, it can be a good idea to drop the old IP address based annotation completely and calculate the internalIP and podCIDR out of the new node prefix annotation.

old:

metal.ironcore.dev/loopback-address: 2001:db8:dead:beef::1

new:

metadata.metal.ironcore.dev/prefix: 2001:db8:dead:beef::/64

The `metal.ironcore.dev/loopback-address` annotation (a host IP) is
replaced by `metadata.metal.ironcore.dev/prefix`, which carries the
prefix allocated for the Node in CIDR notation.
By convention, the first usable host IP of the prefix is assigned to the
Node itself and reported as its internal IP address.

Signed-off-by: Martin Kalcok <martin.kalcok@sap.com>
@mkalcok mkalcok changed the title node: Avoid collision of podCIDR and node's IP node: Rework podCIDR allocation Oct 29, 2026
@mkalcok
mkalcok marked this pull request as ready for review October 29, 2026 16:56
@mkalcok
mkalcok requested a review from a team as a code owner October 29, 2026 16:56
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fbd3aa25-6cd2-48af-98fa-cf7335dc98fc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@mkalcok

mkalcok commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

PR title and description have been updated to reflect changes based on the previous review commits.

@maxmoehl
maxmoehl self-requested a review October 30, 2026 06:17
@damyan

damyan commented Oct 30, 2026

Copy link
Copy Markdown
Member

LGTM. Though, let's have a manual test in a dev environment first

Instead of deriving the podCIDR from the Node's NodeInternalIP status
address, source it from the prefix annotation of the Server backing
the Node.

The ServerClaim resolution from the Node's providerID is extracted
into getServerClaimForNode and performed once per reconciliation, with
the claim passed to both reconcilePodCIDR and reconcileMaintenance.

Signed-off-by: Martin Kalcok <martin.kalcok@sap.com>
The previous approach to generating a node's podCIDR was to apply a mask
to the node's assigned prefix. This could result in a collision, as the
node's own IP would typically be the first address of the prefix, and as
such, also part of the podCIDR. Any CNI using the podCIDR as an address
pool could assign the node's IP address to one of the pods.

The new approach increments the network portion of the IP address after
applying the mask. This avoids the collision with the node's own IP
address. The podCIDR won't be applied if it falls outside of the node's
assigned prefix. However, since the prefix length used for podCIDR is
typically way smaller than the prefix assigned to the entire host, this
should not be a common issue.

Example:

Old approach
Node prefix   : 2001:db8::/64
Node IP       : 2001:db8::1
podCIDR prefix: /112
podCIDR       : 2001:db8::/112   <--- Overlaps the Node's IP

New approach:
Node prefix   : 2001:db8::/64
Node IP       : 2001:db8::1
podCIDR prefix: /112
podCIDR       : 2001:db8::1:0/112

Signed-off-by: Martin Kalcok <martin.kalcok@sap.com>
@mkalcok

mkalcok commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I also manually tested the change by manually deploying a new zone and the offset mechanism works

root@mgmt-example:~# kubectl get server/mgmt-example-system-0 -o=jsonpath='{.metadata.annotations.metadata\.metal\.ironcore\.dev/prefix}{"\n"}'
2001:db8:e015:302::/64
root@mgmt-example:~# kubectl get node/mgmt-example -o=jsonpath='{.spec.podCIDR}{"\n"}'
2001:db8:e015:302::1:0/112

/cc @damyan

@maxmoehl maxmoehl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! Though you will need a metal maintainer to actually be able to merge this.

@damyan
damyan merged commit b6230b1 into ironcore-dev:main Nov 3, 2026
12 checks passed
@mkalcok

mkalcok commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

muh beautiful commits 😢

@hardikdr hardikdr added the area/metal-automation Automation processes within the Metal project. label Nov 9, 2026
@hardikdr hardikdr added this to Roadmap Nov 9, 2026
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Nov 9, 2026
@afritzler afritzler added the enhancement New feature or request label Nov 10, 2026
@afritzler afritzler changed the title node: Rework podCIDR allocation Rework podCIDR allocation Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/metal-automation Automation processes within the Metal project. enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants