Set default ClusterCIDR through the PodCIDR

This commit is contained in:
John Gardiner Myers 2021-06-13 22:31:35 -07:00
parent b29c612b9c
commit 51d0697dc3
2 changed files with 4 additions and 7 deletions

View File

@ -116,6 +116,7 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
kcm.AllocateNodeCIDRs = fi.Bool(true)
kcm.ConfigureCloudRoutes = fi.Bool(false)
kcm.ClusterCIDR = clusterSpec.PodCIDR
networking := clusterSpec.Networking
if networking == nil {
@ -125,10 +126,6 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
} else if networking.GCE != nil {
kcm.ConfigureCloudRoutes = fi.Bool(false)
kcm.CIDRAllocatorType = fi.String("CloudAllocator")
if kcm.ClusterCIDR == "" {
kcm.ClusterCIDR = clusterSpec.PodCIDR
}
} else if networking.External != nil {
kcm.ConfigureCloudRoutes = fi.Bool(false)
} else if UsesCNI(networking) {

View File

@ -325,7 +325,7 @@ func (c *populateClusterSpec) assignSubnets(cluster *kopsapi.Cluster) error {
cluster.Spec.KubeControllerManager = &kopsapi.KubeControllerManagerConfig{}
}
if cluster.Spec.KubeControllerManager.ClusterCIDR == "" {
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 {
@ -335,8 +335,8 @@ func (c *populateClusterSpec) assignSubnets(cluster *kopsapi.Cluster) error {
}
ip[nmOnes/8] |= 128 >> (nmOnes % 8)
cidr := net.IPNet{IP: ip, Mask: net.CIDRMask(nmOnes+1, nmBits)}
cluster.Spec.KubeControllerManager.ClusterCIDR = cidr.String()
klog.V(2).Infof("Defaulted KubeControllerManager.ClusterCIDR to %v", cluster.Spec.KubeControllerManager.ClusterCIDR)
cluster.Spec.PodCIDR = cidr.String()
klog.V(2).Infof("Defaulted PodCIDR to %v", cluster.Spec.PodCIDR)
}
if cluster.Spec.ServiceClusterIPRange == "" {