Skip to content

Commit

Permalink
network/cni: Always setup 'lo'
Browse files Browse the repository at this point in the history
backport of kubernetes#29310

See issue kubernetes#28561
  • Loading branch information
euank authored and Patrick Baxter committed Jul 26, 2016
1 parent 32ac4e6 commit 58903a6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/kubelet/network/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
type cniNetworkPlugin struct {
network.NoopNetworkPlugin

loNetwork *cniNetwork
defaultNetwork *cniNetwork
host network.Host
execer utilexec.Interface
Expand Down Expand Up @@ -104,6 +105,23 @@ func (plugin *cniNetworkPlugin) Init(host network.Host, hairpinMode componentcon
return err
}

loConfig, err := libcni.ConfFromBytes([]byte(`{
"cniVersion": "0.1.0",
"name": "cni-loopback",
"type": "loopback"
}`))
if err != nil {
return err
}
cninet := &libcni.CNIConfig{
Path: []string{DefaultCNIDir},
}
plugin.loNetwork = &cniNetwork{
name: "lo",
NetworkConfig: loConfig,
CNIConfig: cninet,
}

plugin.host = host
return nil
}
Expand All @@ -118,6 +136,12 @@ func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubec
return fmt.Errorf("CNI failed to retrieve network namespace path: %v", err)
}

_, err = plugin.loNetwork.addToNetwork(name, namespace, id, netnsPath)
if err != nil {
glog.Errorf("Error while adding to cni lo network: %s", err)
return err
}

_, err = plugin.defaultNetwork.addToNetwork(name, namespace, id, netnsPath)
if err != nil {
glog.Errorf("Error while adding to cni network: %s", err)
Expand Down

0 comments on commit 58903a6

Please sign in to comment.