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
67414afd
Commit
67414afd
authored
Jan 26, 2016
by
Dan Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send PodCIDR to network plugins as an event
parent
fc2929ed
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
10 deletions
+40
-10
kubelet.go
pkg/kubelet/kubelet.go
+19
-5
kubelet_test.go
pkg/kubelet/kubelet_test.go
+3
-3
cni.go
pkg/kubelet/network/cni/cni.go
+3
-0
exec.go
pkg/kubelet/network/exec/exec.go
+3
-0
plugins.go
pkg/kubelet/network/plugins.go
+12
-0
runtime.go
pkg/kubelet/runtime.go
+0
-2
No files found.
pkg/kubelet/kubelet.go
View file @
67414afd
...
@@ -398,7 +398,8 @@ func NewMainKubelet(
...
@@ -398,7 +398,8 @@ func NewMainKubelet(
}
}
klet
.
pleg
=
pleg
.
NewGenericPLEG
(
klet
.
containerRuntime
,
plegChannelCapacity
,
plegRelistPeriod
,
klet
.
podCache
)
klet
.
pleg
=
pleg
.
NewGenericPLEG
(
klet
.
containerRuntime
,
plegChannelCapacity
,
plegRelistPeriod
,
klet
.
podCache
)
klet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
configureCBR0
,
podCIDR
,
klet
.
isContainerRuntimeVersionCompatible
)
klet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
configureCBR0
,
klet
.
isContainerRuntimeVersionCompatible
)
klet
.
updatePodCIDR
(
podCIDR
)
// setup containerGC
// setup containerGC
containerGC
,
err
:=
kubecontainer
.
NewContainerGC
(
klet
.
containerRuntime
,
containerGCPolicy
)
containerGC
,
err
:=
kubecontainer
.
NewContainerGC
(
klet
.
containerRuntime
,
containerGCPolicy
)
...
@@ -2644,9 +2645,7 @@ func (kl *Kubelet) syncNetworkStatus() {
...
@@ -2644,9 +2645,7 @@ func (kl *Kubelet) syncNetworkStatus() {
glog
.
Infof
(
"Flannel server handshake failed %v"
,
err
)
glog
.
Infof
(
"Flannel server handshake failed %v"
,
err
)
return
return
}
}
glog
.
Infof
(
"Setting cidr: %v -> %v"
,
kl
.
updatePodCIDR
(
podCIDR
)
kl
.
runtimeState
.
podCIDR
(),
podCIDR
)
kl
.
runtimeState
.
setPodCIDR
(
podCIDR
)
}
}
if
err
:=
ensureIPTablesMasqRule
(
kl
.
nonMasqueradeCIDR
);
err
!=
nil
{
if
err
:=
ensureIPTablesMasqRule
(
kl
.
nonMasqueradeCIDR
);
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Error on adding ip table rules: %v"
,
err
)
err
=
fmt
.
Errorf
(
"Error on adding ip table rules: %v"
,
err
)
...
@@ -3026,7 +3025,7 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
...
@@ -3026,7 +3025,7 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
}
}
}
}
}
else
if
kl
.
reconcileCIDR
{
}
else
if
kl
.
reconcileCIDR
{
kl
.
runtimeState
.
set
PodCIDR
(
node
.
Spec
.
PodCIDR
)
kl
.
update
PodCIDR
(
node
.
Spec
.
PodCIDR
)
}
}
if
err
:=
kl
.
setNodeStatus
(
node
);
err
!=
nil
{
if
err
:=
kl
.
setNodeStatus
(
node
);
err
!=
nil
{
...
@@ -3445,6 +3444,21 @@ func (kl *Kubelet) GetRuntime() kubecontainer.Runtime {
...
@@ -3445,6 +3444,21 @@ func (kl *Kubelet) GetRuntime() kubecontainer.Runtime {
return
kl
.
containerRuntime
return
kl
.
containerRuntime
}
}
func
(
kl
*
Kubelet
)
updatePodCIDR
(
cidr
string
)
{
if
kl
.
runtimeState
.
podCIDR
()
==
cidr
{
return
}
glog
.
Infof
(
"Setting Pod CIDR: %v -> %v"
,
kl
.
runtimeState
.
podCIDR
(),
cidr
)
kl
.
runtimeState
.
setPodCIDR
(
cidr
)
if
kl
.
networkPlugin
!=
nil
{
details
:=
make
(
map
[
string
]
interface
{})
details
[
network
.
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
]
=
cidr
kl
.
networkPlugin
.
Event
(
network
.
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
,
details
)
}
}
var
minRsrc
=
resource
.
MustParse
(
"1k"
)
var
minRsrc
=
resource
.
MustParse
(
"1k"
)
var
maxRsrc
=
resource
.
MustParse
(
"1P"
)
var
maxRsrc
=
resource
.
MustParse
(
"1P"
)
...
...
pkg/kubelet/kubelet_test.go
View file @
67414afd
...
@@ -117,7 +117,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
...
@@ -117,7 +117,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
kubelet
.
hostname
=
testKubeletHostname
kubelet
.
hostname
=
testKubeletHostname
kubelet
.
nodeName
=
testKubeletHostname
kubelet
.
nodeName
=
testKubeletHostname
kubelet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
false
,
""
/* Pod CIDR */
,
func
()
error
{
return
nil
})
kubelet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
false
,
func
()
error
{
return
nil
})
kubelet
.
networkPlugin
,
_
=
network
.
InitNetworkPlugin
([]
network
.
NetworkPlugin
{},
""
,
network
.
NewFakeHost
(
nil
))
kubelet
.
networkPlugin
,
_
=
network
.
InitNetworkPlugin
([]
network
.
NetworkPlugin
{},
""
,
network
.
NewFakeHost
(
nil
))
if
tempDir
,
err
:=
ioutil
.
TempDir
(
"/tmp"
,
"kubelet_test."
);
err
!=
nil
{
if
tempDir
,
err
:=
ioutil
.
TempDir
(
"/tmp"
,
"kubelet_test."
);
err
!=
nil
{
t
.
Fatalf
(
"can't make a temp rootdir: %v"
,
err
)
t
.
Fatalf
(
"can't make a temp rootdir: %v"
,
err
)
...
@@ -2961,7 +2961,7 @@ func TestDockerRuntimeVersion(t *testing.T) {
...
@@ -2961,7 +2961,7 @@ func TestDockerRuntimeVersion(t *testing.T) {
},
},
}
}
kubelet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
false
,
""
,
kubelet
.
isContainerRuntimeVersionCompatible
)
kubelet
.
runtimeState
=
newRuntimeState
(
maxWaitForContainerRuntime
,
false
,
kubelet
.
isContainerRuntimeVersionCompatible
)
kubelet
.
updateRuntimeUp
()
kubelet
.
updateRuntimeUp
()
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
@@ -3424,7 +3424,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
...
@@ -3424,7 +3424,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
},
},
},
},
}
}
kubelet
.
runtimeState
=
newRuntimeState
(
time
.
Duration
(
0
),
false
,
""
/* Pod CIDR */
,
func
()
error
{
return
nil
})
kubelet
.
runtimeState
=
newRuntimeState
(
time
.
Duration
(
0
),
false
,
func
()
error
{
return
nil
})
kubelet
.
updateRuntimeUp
()
kubelet
.
updateRuntimeUp
()
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
...
pkg/kubelet/network/cni/cni.go
View file @
67414afd
...
@@ -97,6 +97,9 @@ func (plugin *cniNetworkPlugin) Init(host network.Host) error {
...
@@ -97,6 +97,9 @@ func (plugin *cniNetworkPlugin) Init(host network.Host) error {
return
nil
return
nil
}
}
func
(
plugin
*
cniNetworkPlugin
)
Event
(
name
string
,
details
map
[
string
]
interface
{})
{
}
func
(
plugin
*
cniNetworkPlugin
)
Name
()
string
{
func
(
plugin
*
cniNetworkPlugin
)
Name
()
string
{
return
CNIPluginName
return
CNIPluginName
}
}
...
...
pkg/kubelet/network/exec/exec.go
View file @
67414afd
...
@@ -120,6 +120,9 @@ func (plugin *execNetworkPlugin) getExecutable() string {
...
@@ -120,6 +120,9 @@ func (plugin *execNetworkPlugin) getExecutable() string {
return
path
.
Join
(
plugin
.
execPath
,
execName
)
return
path
.
Join
(
plugin
.
execPath
,
execName
)
}
}
func
(
plugin
*
execNetworkPlugin
)
Event
(
name
string
,
details
map
[
string
]
interface
{})
{
}
func
(
plugin
*
execNetworkPlugin
)
Name
()
string
{
func
(
plugin
*
execNetworkPlugin
)
Name
()
string
{
return
plugin
.
execName
return
plugin
.
execName
}
}
...
...
pkg/kubelet/network/plugins.go
View file @
67414afd
...
@@ -33,12 +33,21 @@ import (
...
@@ -33,12 +33,21 @@ import (
const
DefaultPluginName
=
"kubernetes.io/no-op"
const
DefaultPluginName
=
"kubernetes.io/no-op"
// Called when the node's Pod CIDR is known when using the
// controller manager's --allocate-node-cidrs=true option
const
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
=
"pod-cidr-change"
const
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
=
"pod-cidr"
// Plugin is an interface to network plugins for the kubelet
// Plugin is an interface to network plugins for the kubelet
type
NetworkPlugin
interface
{
type
NetworkPlugin
interface
{
// Init initializes the plugin. This will be called exactly once
// Init initializes the plugin. This will be called exactly once
// before any other methods are called.
// before any other methods are called.
Init
(
host
Host
)
error
Init
(
host
Host
)
error
// Called on various events like:
// NET_PLUGIN_EVENT_POD_CIDR_CHANGE
Event
(
name
string
,
details
map
[
string
]
interface
{})
// Name returns the plugin's name. This will be used when searching
// Name returns the plugin's name. This will be used when searching
// for a plugin by name, e.g.
// for a plugin by name, e.g.
Name
()
string
Name
()
string
...
@@ -130,6 +139,9 @@ func (plugin *noopNetworkPlugin) Init(host Host) error {
...
@@ -130,6 +139,9 @@ func (plugin *noopNetworkPlugin) Init(host Host) error {
return
nil
return
nil
}
}
func
(
plugin
*
noopNetworkPlugin
)
Event
(
name
string
,
details
map
[
string
]
interface
{})
{
}
func
(
plugin
*
noopNetworkPlugin
)
Name
()
string
{
func
(
plugin
*
noopNetworkPlugin
)
Name
()
string
{
return
DefaultPluginName
return
DefaultPluginName
}
}
...
...
pkg/kubelet/runtime.go
View file @
67414afd
...
@@ -94,7 +94,6 @@ func (s *runtimeState) errors() []string {
...
@@ -94,7 +94,6 @@ func (s *runtimeState) errors() []string {
func
newRuntimeState
(
func
newRuntimeState
(
runtimeSyncThreshold
time
.
Duration
,
runtimeSyncThreshold
time
.
Duration
,
configureNetwork
bool
,
configureNetwork
bool
,
cidr
string
,
runtimeCompatibility
func
()
error
,
runtimeCompatibility
func
()
error
,
)
*
runtimeState
{
)
*
runtimeState
{
var
networkError
error
=
nil
var
networkError
error
=
nil
...
@@ -105,7 +104,6 @@ func newRuntimeState(
...
@@ -105,7 +104,6 @@ func newRuntimeState(
lastBaseRuntimeSync
:
time
.
Time
{},
lastBaseRuntimeSync
:
time
.
Time
{},
baseRuntimeSyncThreshold
:
runtimeSyncThreshold
,
baseRuntimeSyncThreshold
:
runtimeSyncThreshold
,
networkError
:
networkError
,
networkError
:
networkError
,
cidr
:
cidr
,
internalError
:
nil
,
internalError
:
nil
,
runtimeCompatibility
:
runtimeCompatibility
,
runtimeCompatibility
:
runtimeCompatibility
,
}
}
...
...
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