From 8f7b5bcfd33f12ce43733624c3308b906b3ea80a Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Mon, 11 Jul 2016 17:08:33 -0700 Subject: [PATCH] network/cni: Always setup 'lo' See issue #28561 --- pkg/kubelet/network/cni/cni.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/kubelet/network/cni/cni.go b/pkg/kubelet/network/cni/cni.go index 81e7d0c0cfa..4830aa79efe 100644 --- a/pkg/kubelet/network/cni/cni.go +++ b/pkg/kubelet/network/cni/cni.go @@ -39,6 +39,7 @@ const ( type cniNetworkPlugin struct { network.NoopNetworkPlugin + loNetwork *cniNetwork defaultNetwork *cniNetwork host network.Host execer utilexec.Interface @@ -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 } @@ -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)