mirror of https://github.com/kubernetes/kops.git
Set default ClusterCIDR through the PodCIDR
This commit is contained in:
parent
b29c612b9c
commit
51d0697dc3
|
|
@ -116,6 +116,7 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
|
||||||
|
|
||||||
kcm.AllocateNodeCIDRs = fi.Bool(true)
|
kcm.AllocateNodeCIDRs = fi.Bool(true)
|
||||||
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
||||||
|
kcm.ClusterCIDR = clusterSpec.PodCIDR
|
||||||
|
|
||||||
networking := clusterSpec.Networking
|
networking := clusterSpec.Networking
|
||||||
if networking == nil {
|
if networking == nil {
|
||||||
|
|
@ -125,10 +126,6 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
|
||||||
} else if networking.GCE != nil {
|
} else if networking.GCE != nil {
|
||||||
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
||||||
kcm.CIDRAllocatorType = fi.String("CloudAllocator")
|
kcm.CIDRAllocatorType = fi.String("CloudAllocator")
|
||||||
|
|
||||||
if kcm.ClusterCIDR == "" {
|
|
||||||
kcm.ClusterCIDR = clusterSpec.PodCIDR
|
|
||||||
}
|
|
||||||
} else if networking.External != nil {
|
} else if networking.External != nil {
|
||||||
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
kcm.ConfigureCloudRoutes = fi.Bool(false)
|
||||||
} else if UsesCNI(networking) {
|
} else if UsesCNI(networking) {
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ func (c *populateClusterSpec) assignSubnets(cluster *kopsapi.Cluster) error {
|
||||||
cluster.Spec.KubeControllerManager = &kopsapi.KubeControllerManagerConfig{}
|
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
|
// Allocate as big a range as possible: the NonMasqueradeCIDR mask + 1, with a '1' in the extra bit
|
||||||
ip := nonMasqueradeCIDR.IP.Mask(nonMasqueradeCIDR.Mask)
|
ip := nonMasqueradeCIDR.IP.Mask(nonMasqueradeCIDR.Mask)
|
||||||
if nmBits > 32 && nmOnes < 63 {
|
if nmBits > 32 && nmOnes < 63 {
|
||||||
|
|
@ -335,8 +335,8 @@ func (c *populateClusterSpec) assignSubnets(cluster *kopsapi.Cluster) error {
|
||||||
}
|
}
|
||||||
ip[nmOnes/8] |= 128 >> (nmOnes % 8)
|
ip[nmOnes/8] |= 128 >> (nmOnes % 8)
|
||||||
cidr := net.IPNet{IP: ip, Mask: net.CIDRMask(nmOnes+1, nmBits)}
|
cidr := net.IPNet{IP: ip, Mask: net.CIDRMask(nmOnes+1, nmBits)}
|
||||||
cluster.Spec.KubeControllerManager.ClusterCIDR = cidr.String()
|
cluster.Spec.PodCIDR = cidr.String()
|
||||||
klog.V(2).Infof("Defaulted KubeControllerManager.ClusterCIDR to %v", cluster.Spec.KubeControllerManager.ClusterCIDR)
|
klog.V(2).Infof("Defaulted PodCIDR to %v", cluster.Spec.PodCIDR)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster.Spec.ServiceClusterIPRange == "" {
|
if cluster.Spec.ServiceClusterIPRange == "" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue