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
ee2ea223
Commit
ee2ea223
authored
Jan 23, 2018
by
Dan Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubenet: accept a list of CNI binary plugin paths
parent
69ac723b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
plugins.go
cmd/kubelet/app/plugins.go
+1
-1
kubenet_linux.go
pkg/kubelet/network/kubenet/kubenet_linux.go
+17
-17
No files found.
cmd/kubelet/app/plugins.go
View file @
ee2ea223
...
@@ -119,7 +119,7 @@ func ProbeNetworkPlugins(cniConfDir, cniBinDir string) []network.NetworkPlugin {
...
@@ -119,7 +119,7 @@ func ProbeNetworkPlugins(cniConfDir, cniBinDir string) []network.NetworkPlugin {
// for each existing plugin, add to the list
// for each existing plugin, add to the list
allPlugins
=
append
(
allPlugins
,
cni
.
ProbeNetworkPlugins
(
cniConfDir
,
[]
string
{
cniBinDir
})
...
)
allPlugins
=
append
(
allPlugins
,
cni
.
ProbeNetworkPlugins
(
cniConfDir
,
[]
string
{
cniBinDir
})
...
)
allPlugins
=
append
(
allPlugins
,
kubenet
.
NewPlugin
(
cniBinDir
))
allPlugins
=
append
(
allPlugins
,
kubenet
.
NewPlugin
(
[]
string
{
cniBinDir
}
))
return
allPlugins
return
allPlugins
}
}
pkg/kubelet/network/kubenet/kubenet_linux.go
View file @
ee2ea223
...
@@ -66,7 +66,7 @@ const (
...
@@ -66,7 +66,7 @@ const (
defaultIPAMDir
=
"/var/lib/cni/networks"
defaultIPAMDir
=
"/var/lib/cni/networks"
)
)
// CNI plugins required by kubenet in /opt/cni/bin or
vendor
directory
// CNI plugins required by kubenet in /opt/cni/bin or
user-specified
directory
var
requiredCNIPlugins
=
[
...
]
string
{
"bridge"
,
"host-local"
,
"loopback"
}
var
requiredCNIPlugins
=
[
...
]
string
{
"bridge"
,
"host-local"
,
"loopback"
}
type
kubenetNetworkPlugin
struct
{
type
kubenetNetworkPlugin
struct
{
...
@@ -91,15 +91,15 @@ type kubenetNetworkPlugin struct {
...
@@ -91,15 +91,15 @@ type kubenetNetworkPlugin struct {
iptables
utiliptables
.
Interface
iptables
utiliptables
.
Interface
sysctl
utilsysctl
.
Interface
sysctl
utilsysctl
.
Interface
ebtables
utilebtables
.
Interface
ebtables
utilebtables
.
Interface
//
vendorDir
is passed by kubelet cni-bin-dir parameter.
//
binDirs
is passed by kubelet cni-bin-dir parameter.
// kubenet will search for
cni binaries in DefaultCNIDir first, then continue to vendorDir
.
// kubenet will search for
CNI binaries in DefaultCNIDir first, then continue to binDirs
.
vendorDir
string
binDirs
[]
string
nonMasqueradeCIDR
string
nonMasqueradeCIDR
string
podCidr
string
podCidr
string
gateway
net
.
IP
gateway
net
.
IP
}
}
func
NewPlugin
(
networkPluginDir
string
)
network
.
NetworkPlugin
{
func
NewPlugin
(
networkPluginDir
s
[]
string
)
network
.
NetworkPlugin
{
protocol
:=
utiliptables
.
ProtocolIpv4
protocol
:=
utiliptables
.
ProtocolIpv4
execer
:=
utilexec
.
New
()
execer
:=
utilexec
.
New
()
dbus
:=
utildbus
.
New
()
dbus
:=
utildbus
.
New
()
...
@@ -110,7 +110,7 @@ func NewPlugin(networkPluginDir string) network.NetworkPlugin {
...
@@ -110,7 +110,7 @@ func NewPlugin(networkPluginDir string) network.NetworkPlugin {
execer
:
utilexec
.
New
(),
execer
:
utilexec
.
New
(),
iptables
:
iptInterface
,
iptables
:
iptInterface
,
sysctl
:
sysctl
,
sysctl
:
sysctl
,
vendorDir
:
networkPluginDir
,
binDirs
:
append
([]
string
{
DefaultCNIDir
},
networkPluginDirs
...
)
,
hostportSyncer
:
hostport
.
NewHostportSyncer
(
iptInterface
),
hostportSyncer
:
hostport
.
NewHostportSyncer
(
iptInterface
),
hostportManager
:
hostport
.
NewHostportManager
(
iptInterface
),
hostportManager
:
hostport
.
NewHostportManager
(
iptInterface
),
nonMasqueradeCIDR
:
"10.0.0.0/8"
,
nonMasqueradeCIDR
:
"10.0.0.0/8"
,
...
@@ -121,9 +121,7 @@ func (plugin *kubenetNetworkPlugin) Init(host network.Host, hairpinMode kubeletc
...
@@ -121,9 +121,7 @@ func (plugin *kubenetNetworkPlugin) Init(host network.Host, hairpinMode kubeletc
plugin
.
host
=
host
plugin
.
host
=
host
plugin
.
hairpinMode
=
hairpinMode
plugin
.
hairpinMode
=
hairpinMode
plugin
.
nonMasqueradeCIDR
=
nonMasqueradeCIDR
plugin
.
nonMasqueradeCIDR
=
nonMasqueradeCIDR
plugin
.
cniConfig
=
&
libcni
.
CNIConfig
{
plugin
.
cniConfig
=
&
libcni
.
CNIConfig
{
Path
:
plugin
.
binDirs
}
Path
:
[]
string
{
DefaultCNIDir
,
plugin
.
vendorDir
},
}
if
mtu
==
network
.
UseDefaultMTU
{
if
mtu
==
network
.
UseDefaultMTU
{
if
link
,
err
:=
findMinMTU
();
err
==
nil
{
if
link
,
err
:=
findMinMTU
();
err
==
nil
{
...
@@ -564,22 +562,24 @@ func (plugin *kubenetNetworkPlugin) Status() error {
...
@@ -564,22 +562,24 @@ func (plugin *kubenetNetworkPlugin) Status() error {
return
fmt
.
Errorf
(
"Kubenet does not have netConfig. This is most likely due to lack of PodCIDR"
)
return
fmt
.
Errorf
(
"Kubenet does not have netConfig. This is most likely due to lack of PodCIDR"
)
}
}
if
!
plugin
.
check
CNIPlugin
()
{
if
!
plugin
.
check
RequiredCNIPlugins
()
{
return
fmt
.
Errorf
(
"could not locate kubenet required CNI plugins %v at %q or %q"
,
requiredCNIPlugins
,
DefaultCNIDir
,
plugin
.
vendorDir
)
return
fmt
.
Errorf
(
"could not locate kubenet required CNI plugins %v at %q or %q"
,
requiredCNIPlugins
,
plugin
.
binDirs
)
}
}
return
nil
return
nil
}
}
// checkCNIPlugin returns if all kubenet required cni plugins can be found at /opt/cni/bin or user specified NetworkPluginDir.
// checkRequiredCNIPlugins returns if all kubenet required cni plugins can be found at /opt/cni/bin or user specified NetworkPluginDir.
func
(
plugin
*
kubenetNetworkPlugin
)
checkCNIPlugin
()
bool
{
func
(
plugin
*
kubenetNetworkPlugin
)
checkRequiredCNIPlugins
()
bool
{
if
plugin
.
checkCNIPluginInDir
(
DefaultCNIDir
)
||
plugin
.
checkCNIPluginInDir
(
plugin
.
vendorDir
)
{
for
_
,
dir
:=
range
plugin
.
binDirs
{
return
true
if
plugin
.
checkRequiredCNIPluginsInOneDir
(
dir
)
{
return
true
}
}
}
return
false
return
false
}
}
// check
CNIPluginInDir returns
if all required cni plugins are placed in dir
// check
RequiredCNIPluginsInOneDir returns true
if all required cni plugins are placed in dir
func
(
plugin
*
kubenetNetworkPlugin
)
check
CNIPluginIn
Dir
(
dir
string
)
bool
{
func
(
plugin
*
kubenetNetworkPlugin
)
check
RequiredCNIPluginsInOne
Dir
(
dir
string
)
bool
{
files
,
err
:=
ioutil
.
ReadDir
(
dir
)
files
,
err
:=
ioutil
.
ReadDir
(
dir
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
return
false
...
...
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