mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #19580 from WeixuZhuang/node
resolve the bug when cluster CIDR is not /8
This commit is contained in:
commit
94b2490eba
@ -19,6 +19,7 @@ package node
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -212,8 +213,9 @@ func (nc *NodeController) generateAvailableCIDRs() {
|
||||
nc.generatedCIDR = true
|
||||
// Generate all available CIDRs here, since there will not be manay
|
||||
// available CIDRs. Set will be small, it will use less than 1MB memory
|
||||
cidrIP := nc.clusterCIDR.IP.To4()
|
||||
nc.maxCIDRs = (256-int(cidrIP[1]))*256 - int(cidrIP[2])
|
||||
|
||||
cidrSize, _ := nc.clusterCIDR.Mask.Size()
|
||||
nc.maxCIDRs = int(math.Pow(2, (float64)(24-cidrSize)))
|
||||
|
||||
for i := 0; i <= nc.maxCIDRs; i++ {
|
||||
nc.availableCIDRs.Insert(i)
|
||||
|
Loading…
Reference in New Issue
Block a user