Merge pull request #85367 from aramase/node-cidr-followup

[kube controller manager] add comments for compatibility
This commit is contained in:
Kubernetes Prow Robot 2019-11-15 19:09:54 -08:00 committed by GitHub
commit c3f8d700ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -159,8 +159,12 @@ func startNodeIpamController(ctx ControllerContext) (http.Handler, bool, error)
var nodeCIDRMaskSizeIPv4, nodeCIDRMaskSizeIPv6 int
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.IPv6DualStack) {
// only --node-cidr-mask-size-ipv4 and --node-cidr-mask-size-ipv6 supported with dual stack clusters.
// --node-cidr-mask-size flag is incompatible with dual stack clusters.
nodeCIDRMaskSizeIPv4, nodeCIDRMaskSizeIPv6, err = setNodeCIDRMaskSizesDualStack(ctx.ComponentConfig.NodeIPAMController)
} else {
// only --node-cidr-mask-size supported with single stack clusters.
// --node-cidr-mask-size-ipv4 and --node-cidr-mask-size-ipv6 flags are incompatible with dual stack clusters.
nodeCIDRMaskSizeIPv4, nodeCIDRMaskSizeIPv6, err = setNodeCIDRMaskSizes(ctx.ComponentConfig.NodeIPAMController)
}
@ -623,12 +627,13 @@ func setNodeCIDRMaskSizesDualStack(cfg nodeipamconfig.NodeIPAMControllerConfigur
// getNodeCIDRMaskSizes is a helper function that helps the generate the node cidr mask
// sizes slice based on the cluster cidr slice
func getNodeCIDRMaskSizes(clusterCIDRs []*net.IPNet, maskSizeIPv4, maskSizeIPv6 int) []int {
nodeMaskCIDRs := []int{}
for _, clusterCIDR := range clusterCIDRs {
nodeMaskCIDRs := make([]int, len(clusterCIDRs))
for idx, clusterCIDR := range clusterCIDRs {
if netutils.IsIPv6CIDR(clusterCIDR) {
nodeMaskCIDRs = append(nodeMaskCIDRs, maskSizeIPv6)
nodeMaskCIDRs[idx] = maskSizeIPv6
} else {
nodeMaskCIDRs = append(nodeMaskCIDRs, maskSizeIPv4)
nodeMaskCIDRs[idx] = maskSizeIPv4
}
}
return nodeMaskCIDRs

View File

@ -23,9 +23,12 @@ type NodeIPAMControllerConfiguration struct {
// secondaryServiceCIDR is CIDR Range for Services in cluster. This is used in dual stack clusters. SecondaryServiceCIDR must be of different IP family than ServiceCIDR
SecondaryServiceCIDR string
// NodeCIDRMaskSize is the mask size for node cidr in single-stack cluster.
// This can be used only with single stack clusters and is incompatible with dual stack clusters.
NodeCIDRMaskSize int32
// NodeCIDRMaskSizeIPv4 is the mask size for node cidr in dual-stack cluster.
// NodeCIDRMaskSizeIPv4 is the mask size for IPv4 node cidr in dual-stack cluster.
// This can be used only with dual stack clusters and is incompatible with single stack clusters.
NodeCIDRMaskSizeIPv4 int32
// NodeCIDRMaskSizeIPv6 is the mask size for node cidr in dual-stack cluster.
// NodeCIDRMaskSizeIPv6 is the mask size for IPv6 node cidr in dual-stack cluster.
// This can be used only with dual stack clusters and is incompatible with single stack clusters.
NodeCIDRMaskSizeIPv6 int32
}