Provide ability to set lo up without CNI
Signed-off-by: Michael Zappa <michael.zappa@gmail.com>
This commit is contained in:
@@ -37,10 +37,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// networkAttachCount is the minimum number of networks the PodSandbox
|
||||
// attaches to
|
||||
const networkAttachCount = 2
|
||||
|
||||
// initPlatform handles linux specific initialization for the CRI service.
|
||||
func (c *criService) initPlatform() (err error) {
|
||||
if userns.RunningInUserNS() {
|
||||
@@ -69,6 +65,12 @@ func (c *criService) initPlatform() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
networkAttachCount := 2
|
||||
|
||||
if c.Config().UseInternalLoopback {
|
||||
networkAttachCount = 1
|
||||
}
|
||||
|
||||
c.netPlugin = make(map[string]cni.CNI)
|
||||
for name, dir := range pluginDirs {
|
||||
max := c.config.NetworkPluginMaxConfNum
|
||||
@@ -78,9 +80,10 @@ func (c *criService) initPlatform() (err error) {
|
||||
}
|
||||
}
|
||||
// Pod needs to attach to at least loopback network and a non host network,
|
||||
// hence networkAttachCount is 2. If there are more network configs the
|
||||
// pod will be attached to all the networks but we will only use the ip
|
||||
// of the default network interface as the pod IP.
|
||||
// hence networkAttachCount is 2 if the CNI plugin is used and
|
||||
// 1 if the internal mechanism for setting lo to up is used.
|
||||
// If there are more network configs the pod will be attached to all the networks
|
||||
// but we will only use the ip of the default network interface as the pod IP.
|
||||
i, err := cni.New(cni.WithMinNetworkCount(networkAttachCount),
|
||||
cni.WithPluginConfDir(dir),
|
||||
cni.WithPluginMaxConfNum(max),
|
||||
@@ -110,5 +113,9 @@ func (c *criService) initPlatform() (err error) {
|
||||
|
||||
// cniLoadOptions returns cni load options for the linux.
|
||||
func (c *criService) cniLoadOptions() []cni.Opt {
|
||||
if c.config.UseInternalLoopback {
|
||||
return []cni.Opt{cni.WithDefaultConf}
|
||||
}
|
||||
|
||||
return []cni.Opt{cni.WithLoNetwork, cni.WithDefaultConf}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user