Skip to content

Commit

Permalink
feat: ipv6 small subnets
Browse files Browse the repository at this point in the history
Set a limit of 32 pods per node in your Kubernetes cluster.
Some cloud providers offer a /123 IPv6 subnet for nodes, which is typically sufficient for most use cases.

Signed-off-by: Serge Logvinov <[email protected]>
  • Loading branch information
sergelogvinov committed Oct 21, 2024
1 parent 68d4133 commit 82009ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/nodeipam/ipam/cloud_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,10 @@ func (r *cloudAllocator) addCIDRSet(cidr string) error {
}

mask = 80
case mask > 120:
case mask > 123:
return fmt.Errorf("CIDRv6 is too small: %v", subnet.String())
case mask > 119:
break
default:
mask += 16
}
Expand Down
14 changes: 13 additions & 1 deletion pkg/nodeipam/ipam/cloud_allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,23 @@ func TestAddCIDRSet(t *testing.T) {
expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:0/112"),
},
{
name: "CIDRv6 with mask size 120",
name: "CIDRv6 with mask size 120, 256 pods",
cidr: "2000::aaaa:bbbb:cccc:123/120",
expectedSize: 1,
expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:100/120"),
},
{
name: "CIDRv6 with mask size 122, 64 pods",
cidr: "2000::aaaa:bbbb:cccc:123/122",
expectedSize: 1,
expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:100/122"),
},
{
name: "CIDRv6 with mask size 123, 32 pods",
cidr: "2000::aaaa:bbbb:cccc:123/123",
expectedSize: 1,
expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:120/123"),
},
{
name: "CIDRv6 with mask size 124",
cidr: "2000::aaaa:bbbb:cccc:123/124",
Expand Down

0 comments on commit 82009ed

Please sign in to comment.