Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate smaller IPv6 PodCIDRs by default #11772

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions upup/pkg/fi/cloudup/populate_cluster_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ func (c *populateClusterSpec) assignSubnets(cluster *kopsapi.Cluster) error {
if cluster.Spec.PodCIDR == "" {
// Allocate as big a range as possible: the NonMasqueradeCIDR mask + 1, with a '1' in the extra bit
ip := nonMasqueradeCIDR.IP.Mask(nonMasqueradeCIDR.Mask)
if nmBits > 32 && nmOnes < 63 {
// Max size of IPv6 network is 64
// Technically, the max size of IPv4 network is 24, but nobody has a /7 to allocate.
nmOnes = 63
if nmBits > 32 && nmOnes < 95 {
// The maximum size of an IPv6 ClusterCIDR is /64, but a /112 node CIDR gives far more addresses
// than Kubernetes can handle on a node and is more visually pleasing.
// Technically, the maximum size of an IPv4 ClusterCIDR is /8, but nobody has a /7 to allocate.
nmOnes = 95
}
ip[nmOnes/8] |= 128 >> (nmOnes % 8)
cidr := net.IPNet{IP: ip, Mask: net.CIDRMask(nmOnes+1, nmBits)}
Expand Down
12 changes: 6 additions & 6 deletions upup/pkg/fi/cloudup/populate_cluster_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ func TestPopulateCluster_Subnets(t *testing.T) {
ExpectedServiceClusterIPRange: "10.0.0.0/12",
},
{
NonMasqueradeCIDR: "fd00:10:96::/64",
ExpectedClusterCIDR: "fd00:10:96:0:8000::/65",
NonMasqueradeCIDR: "fd00:10:96::/96",
ExpectedClusterCIDR: "fd00:10:96::8000:0/97",
ExpectedServiceClusterIPRange: "fd00:10:96::/108",
},
{
NonMasqueradeCIDR: "fd00:10:96::/63",
ExpectedClusterCIDR: "fd00:10:96:1::/64",
NonMasqueradeCIDR: "fd00:10:96::/95",
ExpectedClusterCIDR: "fd00:10:96::1:0:0/96",
ExpectedServiceClusterIPRange: "fd00:10:96::/108",
},
{
NonMasqueradeCIDR: "fd00:10:96::/62",
ExpectedClusterCIDR: "fd00:10:96:1::/64",
NonMasqueradeCIDR: "fd00:10:96::/94",
ExpectedClusterCIDR: "fd00:10:96::1:0:0/96",
ExpectedServiceClusterIPRange: "fd00:10:96::/108",
},
{
Expand Down