@@ -28,20 +28,21 @@ import (
2828 v1 "k8s.io/client-go/informers/core/v1"
2929 "k8s.io/client-go/kubernetes"
3030 cloudprovider "k8s.io/cloud-provider"
31- nodeipamcontroller "k8s.io/kubernetes/pkg/controller/nodeipam"
32- "k8s.io/kubernetes/pkg/controller/nodeipam/ipam"
3331 netutils "k8s.io/utils/net"
32+
33+ nodeipamcontroller "github.com/linode/linode-cloud-controller-manager/cloud/nodeipam"
34+ "github.com/linode/linode-cloud-controller-manager/cloud/nodeipam/ipam"
3435)
3536
3637const (
37- maxAllowedNodeCIDRs = 2
38+ maxAllowedNodeCIDRsIPv4 = 1
3839)
3940
4041var (
4142 // defaultNodeMaskCIDRIPv4 is default mask size for IPv4 node cidr
4243 defaultNodeMaskCIDRIPv4 = 24
4344 // defaultNodeMaskCIDRIPv6 is default mask size for IPv6 node cidr
44- defaultNodeMaskCIDRIPv6 = 64
45+ defaultNodeMaskCIDRIPv6 = 112
4546)
4647
4748func startNodeIpamController (stopCh <- chan struct {}, cloud cloudprovider.Interface , nodeInformer v1.NodeInformer , kubeclient kubernetes.Interface ) error {
@@ -54,19 +55,13 @@ func startNodeIpamController(stopCh <-chan struct{}, cloud cloudprovider.Interfa
5455 }
5556
5657 // failure: bad cidrs in config
57- clusterCIDRs , dualStack , err := processCIDRs (Options .ClusterCIDRIPv4 )
58+ clusterCIDRs , err := processCIDRs (Options .ClusterCIDRIPv4 )
5859 if err != nil {
5960 return fmt .Errorf ("processCIDRs failed: %w" , err )
6061 }
6162
62- // failure: more than one cidr but they are not configured as dual stack
63- if len (clusterCIDRs ) > 1 && ! dualStack {
64- return fmt .Errorf ("len of ClusterCIDRs==%v and they are not configured as dual stack (at least one from each IPFamily" , len (clusterCIDRs ))
65- }
66-
67- // failure: more than cidrs is not allowed even with dual stack
68- if len (clusterCIDRs ) > maxAllowedNodeCIDRs {
69- return fmt .Errorf ("len of clusters is:%v > more than max allowed of %d" , len (clusterCIDRs ), maxAllowedNodeCIDRs )
63+ if len (clusterCIDRs ) > maxAllowedNodeCIDRsIPv4 {
64+ return fmt .Errorf ("too many clusterCIDRs specified for ipv4, max allowed is %d" , maxAllowedNodeCIDRsIPv4 )
7065 }
7166
7267 /* TODO: uncomment and fix if we want to support service cidr overlap with nodecidr
@@ -98,7 +93,7 @@ func startNodeIpamController(stopCh <-chan struct{}, cloud cloudprovider.Interfa
9893 }
9994 */
10095
101- nodeCIDRMaskSizes := setNodeCIDRMaskSizes (clusterCIDRs )
96+ nodeCIDRMaskSizes := setNodeCIDRMaskSizes ()
10297
10398 ctx := wait .ContextForChannel (stopCh )
10499
@@ -111,7 +106,7 @@ func startNodeIpamController(stopCh <-chan struct{}, cloud cloudprovider.Interfa
111106 serviceCIDR ,
112107 secondaryServiceCIDR ,
113108 nodeCIDRMaskSizes ,
114- ipam .RangeAllocatorType ,
109+ ipam .CloudAllocatorType ,
115110 )
116111 if err != nil {
117112 return err
@@ -121,47 +116,25 @@ func startNodeIpamController(stopCh <-chan struct{}, cloud cloudprovider.Interfa
121116 return nil
122117}
123118
124- // processCIDRs is a helper function that works on a comma separated cidrs and returns
125- // a list of typed cidrs
126- // a flag if cidrs represents a dual stack
127- // error if failed to parse any of the cidrs
128- func processCIDRs (cidrsList string ) ([]* net.IPNet , bool , error ) {
119+ // processCIDR is a helper function that works on cidr and returns a list of typed cidrs
120+ // error if failed to parse the cidr
121+ func processCIDRs (cidrsList string ) ([]* net.IPNet , error ) {
129122 cidrsSplit := strings .Split (strings .TrimSpace (cidrsList ), "," )
130123
131124 cidrs , err := netutils .ParseCIDRs (cidrsSplit )
132125 if err != nil {
133- return nil , false , err
134- }
135-
136- // if cidrs has an error then the previous call will fail
137- // safe to ignore error checking on next call
138- dualstack , err := netutils .IsDualStackCIDRs (cidrs )
139- if err != nil {
140- return nil , false , fmt .Errorf ("failed to perform dualstack check on cidrs: %w" , err )
126+ return nil , err
141127 }
142128
143- return cidrs , dualstack , nil
129+ return cidrs , nil
144130}
145131
146- func setNodeCIDRMaskSizes (clusterCIDRs []* net.IPNet ) []int {
147- sortedSizes := func (maskSizeIPv4 , maskSizeIPv6 int ) []int {
148- nodeMaskCIDRs := make ([]int , len (clusterCIDRs ))
149-
150- for idx , clusterCIDR := range clusterCIDRs {
151- if netutils .IsIPv6CIDR (clusterCIDR ) {
152- nodeMaskCIDRs [idx ] = maskSizeIPv6
153- } else {
154- nodeMaskCIDRs [idx ] = maskSizeIPv4
155- }
156- }
157- return nodeMaskCIDRs
158- }
159-
132+ func setNodeCIDRMaskSizes () []int {
160133 if Options .NodeCIDRMaskSizeIPv4 != 0 {
161134 defaultNodeMaskCIDRIPv4 = Options .NodeCIDRMaskSizeIPv4
162135 }
163136 if Options .NodeCIDRMaskSizeIPv6 != 0 {
164137 defaultNodeMaskCIDRIPv6 = Options .NodeCIDRMaskSizeIPv6
165138 }
166- return sortedSizes ( defaultNodeMaskCIDRIPv4 , defaultNodeMaskCIDRIPv6 )
139+ return [] int { defaultNodeMaskCIDRIPv4 , defaultNodeMaskCIDRIPv6 }
167140}
0 commit comments