Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0a164760
Commit
0a164760
authored
Apr 23, 2018
by
andrewsykim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renable nodeipam in kube-controller-manager
parent
4692a6bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
65 deletions
+57
-65
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+1
-1
core.go
cmd/kube-controller-manager/app/core.go
+15
-13
node_ipam_controller.go
pkg/controller/nodeipam/node_ipam_controller.go
+40
-50
ipam_test.go
test/integration/ipamperf/ipam_test.go
+1
-1
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
0a164760
...
...
@@ -330,9 +330,9 @@ func NewControllerInitializers(loopMode ControllerLoopMode) map[string]InitFunc
controllers
[
"ttl"
]
=
startTTLController
controllers
[
"bootstrapsigner"
]
=
startBootstrapSignerController
controllers
[
"tokencleaner"
]
=
startTokenCleanerController
controllers
[
"nodeipam"
]
=
startNodeIpamController
if
loopMode
==
IncludeCloudLoops
{
controllers
[
"service"
]
=
startServiceController
controllers
[
"nodeipam"
]
=
startNodeIpamController
controllers
[
"route"
]
=
startRouteController
// TODO: volume controller into the IncludeCloudLoops only set.
// TODO: Separate cluster in cloud check from node lifecycle controller.
...
...
cmd/kube-controller-manager/app/core.go
View file @
0a164760
...
...
@@ -82,20 +82,23 @@ func startServiceController(ctx ControllerContext) (bool, error) {
func
startNodeIpamController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
var
clusterCIDR
*
net
.
IPNet
=
nil
var
serviceCIDR
*
net
.
IPNet
=
nil
if
ctx
.
ComponentConfig
.
KubeCloudShared
.
AllocateNodeCIDRs
{
var
err
error
if
len
(
strings
.
TrimSpace
(
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
))
!=
0
{
_
,
clusterCIDR
,
err
=
net
.
ParseCIDR
(
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
)
if
err
!=
nil
{
glog
.
Warningf
(
"Unsuccessful parsing of cluster CIDR %v: %v"
,
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
,
err
)
}
if
!
ctx
.
ComponentConfig
.
KubeCloudShared
.
AllocateNodeCIDRs
{
return
false
,
nil
}
var
err
error
if
len
(
strings
.
TrimSpace
(
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
))
!=
0
{
_
,
clusterCIDR
,
err
=
net
.
ParseCIDR
(
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
)
if
err
!=
nil
{
glog
.
Warningf
(
"Unsuccessful parsing of cluster CIDR %v: %v"
,
ctx
.
ComponentConfig
.
KubeCloudShared
.
ClusterCIDR
,
err
)
}
}
if
len
(
strings
.
TrimSpace
(
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
))
!=
0
{
_
,
serviceCIDR
,
err
=
net
.
ParseCIDR
(
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
)
if
err
!=
nil
{
glog
.
Warningf
(
"Unsuccessful parsing of service CIDR %v: %v"
,
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
,
err
)
}
if
len
(
strings
.
TrimSpace
(
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
))
!=
0
{
_
,
serviceCIDR
,
err
=
net
.
ParseCIDR
(
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
)
if
err
!=
nil
{
glog
.
Warningf
(
"Unsuccessful parsing of service CIDR %v: %v"
,
ctx
.
ComponentConfig
.
NodeIpamController
.
ServiceCIDR
,
err
)
}
}
...
...
@@ -106,7 +109,6 @@ func startNodeIpamController(ctx ControllerContext) (bool, error) {
clusterCIDR
,
serviceCIDR
,
int
(
ctx
.
ComponentConfig
.
NodeIpamController
.
NodeCIDRMaskSize
),
ctx
.
ComponentConfig
.
KubeCloudShared
.
AllocateNodeCIDRs
,
ipam
.
CIDRAllocatorType
(
ctx
.
ComponentConfig
.
KubeCloudShared
.
CIDRAllocatorType
),
)
if
err
!=
nil
{
...
...
pkg/controller/nodeipam/node_ipam_controller.go
View file @
0a164760
...
...
@@ -58,8 +58,7 @@ const (
// Controller is the controller that manages node ipam state.
type
Controller
struct
{
allocateNodeCIDRs
bool
allocatorType
ipam
.
CIDRAllocatorType
allocatorType
ipam
.
CIDRAllocatorType
cloud
cloudprovider
.
Interface
clusterCIDR
*
net
.
IPNet
...
...
@@ -88,7 +87,6 @@ func NewNodeIpamController(
clusterCIDR
*
net
.
IPNet
,
serviceCIDR
*
net
.
IPNet
,
nodeCIDRMaskSize
int
,
allocateNodeCIDRs
bool
,
allocatorType
ipam
.
CIDRAllocatorType
)
(
*
Controller
,
error
)
{
if
kubeClient
==
nil
{
...
...
@@ -108,54 +106,49 @@ func NewNodeIpamController(
metrics
.
RegisterMetricAndTrackRateLimiterUsage
(
"node_ipam_controller"
,
kubeClient
.
CoreV1
()
.
RESTClient
()
.
GetRateLimiter
())
}
if
allocateNodeCIDRs
{
if
clusterCIDR
==
nil
{
glog
.
Fatal
(
"Controller: Must specify clusterCIDR if allocateNodeCIDRs == true."
)
}
mask
:=
clusterCIDR
.
Mask
if
maskSize
,
_
:=
mask
.
Size
();
maskSize
>
nodeCIDRMaskSize
{
glog
.
Fatal
(
"Controller: Invalid clusterCIDR, mask size of clusterCIDR must be less than nodeCIDRMaskSize."
)
}
if
clusterCIDR
==
nil
{
glog
.
Fatal
(
"Controller: Must specify --cluster-cidr if --allocate-node-cidrs is set"
)
}
mask
:=
clusterCIDR
.
Mask
if
maskSize
,
_
:=
mask
.
Size
();
maskSize
>
nodeCIDRMaskSize
{
glog
.
Fatal
(
"Controller: Invalid --cluster-cidr, mask size of cluster CIDR must be less than --node-cidr-mask-size"
)
}
ic
:=
&
Controller
{
cloud
:
cloud
,
kubeClient
:
kubeClient
,
lookupIP
:
net
.
LookupIP
,
clusterCIDR
:
clusterCIDR
,
serviceCIDR
:
serviceCIDR
,
allocateNodeCIDRs
:
allocateNodeCIDRs
,
allocatorType
:
allocatorType
,
cloud
:
cloud
,
kubeClient
:
kubeClient
,
lookupIP
:
net
.
LookupIP
,
clusterCIDR
:
clusterCIDR
,
serviceCIDR
:
serviceCIDR
,
allocatorType
:
allocatorType
,
}
// TODO: Abstract this check into a generic controller manager should run method.
if
ic
.
allocateNodeCIDRs
{
if
ic
.
allocatorType
==
ipam
.
IPAMFromClusterAllocatorType
||
ic
.
allocatorType
==
ipam
.
IPAMFromCloudAllocatorType
{
cfg
:=
&
ipam
.
Config
{
Resync
:
ipamResyncInterval
,
MaxBackoff
:
ipamMaxBackoff
,
InitialRetry
:
ipamInitialBackoff
,
}
switch
ic
.
allocatorType
{
case
ipam
.
IPAMFromClusterAllocatorType
:
cfg
.
Mode
=
nodesync
.
SyncFromCluster
case
ipam
.
IPAMFromCloudAllocatorType
:
cfg
.
Mode
=
nodesync
.
SyncFromCloud
}
ipamc
,
err
:=
ipam
.
NewController
(
cfg
,
kubeClient
,
cloud
,
clusterCIDR
,
serviceCIDR
,
nodeCIDRMaskSize
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Error creating ipam controller: %v"
,
err
)
}
if
err
:=
ipamc
.
Start
(
nodeInformer
);
err
!=
nil
{
glog
.
Fatalf
(
"Error trying to Init(): %v"
,
err
)
}
}
else
{
var
err
error
ic
.
cidrAllocator
,
err
=
ipam
.
New
(
kubeClient
,
cloud
,
nodeInformer
,
ic
.
allocatorType
,
ic
.
clusterCIDR
,
ic
.
serviceCIDR
,
nodeCIDRMaskSize
)
if
err
!=
nil
{
return
nil
,
err
}
if
ic
.
allocatorType
==
ipam
.
IPAMFromClusterAllocatorType
||
ic
.
allocatorType
==
ipam
.
IPAMFromCloudAllocatorType
{
cfg
:=
&
ipam
.
Config
{
Resync
:
ipamResyncInterval
,
MaxBackoff
:
ipamMaxBackoff
,
InitialRetry
:
ipamInitialBackoff
,
}
switch
ic
.
allocatorType
{
case
ipam
.
IPAMFromClusterAllocatorType
:
cfg
.
Mode
=
nodesync
.
SyncFromCluster
case
ipam
.
IPAMFromCloudAllocatorType
:
cfg
.
Mode
=
nodesync
.
SyncFromCloud
}
ipamc
,
err
:=
ipam
.
NewController
(
cfg
,
kubeClient
,
cloud
,
clusterCIDR
,
serviceCIDR
,
nodeCIDRMaskSize
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Error creating ipam controller: %v"
,
err
)
}
if
err
:=
ipamc
.
Start
(
nodeInformer
);
err
!=
nil
{
glog
.
Fatalf
(
"Error trying to Init(): %v"
,
err
)
}
}
else
{
var
err
error
ic
.
cidrAllocator
,
err
=
ipam
.
New
(
kubeClient
,
cloud
,
nodeInformer
,
ic
.
allocatorType
,
ic
.
clusterCIDR
,
ic
.
serviceCIDR
,
nodeCIDRMaskSize
)
if
err
!=
nil
{
return
nil
,
err
}
}
...
...
@@ -176,11 +169,8 @@ func (nc *Controller) Run(stopCh <-chan struct{}) {
return
}
// TODO: Abstract this check into a generic controller manager should run method.
if
nc
.
allocateNodeCIDRs
{
if
nc
.
allocatorType
!=
ipam
.
IPAMFromClusterAllocatorType
&&
nc
.
allocatorType
!=
ipam
.
IPAMFromCloudAllocatorType
{
go
nc
.
cidrAllocator
.
Run
(
stopCh
)
}
if
nc
.
allocatorType
!=
ipam
.
IPAMFromClusterAllocatorType
&&
nc
.
allocatorType
!=
ipam
.
IPAMFromCloudAllocatorType
{
go
nc
.
cidrAllocator
.
Run
(
stopCh
)
}
<-
stopCh
...
...
test/integration/ipamperf/ipam_test.go
View file @
0a164760
...
...
@@ -53,7 +53,7 @@ func setupAllocator(apiURL string, config *Config, clusterCIDR, serviceCIDR *net
sharedInformer
:=
informers
.
NewSharedInformerFactory
(
clientSet
,
1
*
time
.
Hour
)
ipamController
,
err
:=
nodeipam
.
NewNodeIpamController
(
sharedInformer
.
Core
()
.
V1
()
.
Nodes
(),
config
.
Cloud
,
clientSet
,
clusterCIDR
,
serviceCIDR
,
subnetMaskSize
,
true
,
config
.
AllocatorType
,
clusterCIDR
,
serviceCIDR
,
subnetMaskSize
,
config
.
AllocatorType
,
)
if
err
!=
nil
{
return
nil
,
shutdownFunc
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment