feat: ipv6 small subnets

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 <serge.logvinov@sinextra.dev>
This commit is contained in:
Serge Logvinov
2024-10-21 18:47:21 +03:00
parent 68d41338b1
commit 82009ed898
2 changed files with 16 additions and 2 deletions

View File

@@ -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
}

View File

@@ -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",