mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 21:25:09 +00:00
@@ -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)
|
||||
|
Reference in New Issue
Block a user