Skip to content

Commit

Permalink
add comments for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aramase committed Nov 15, 2019
1 parent f2469a7 commit 128f33b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions cmd/kube-controller-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/nodeipam/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 128f33b

Please sign in to comment.