forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.go
65 lines (51 loc) · 2.19 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package plugin
import (
"fmt"
utilsets "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/apis/componentconfig"
kubeletTypes "k8s.io/kubernetes/pkg/kubelet/container"
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
"github.com/golang/glog"
)
// This kubelet network plugin shim only exists to grab the knetwork.Host
// Everything else is simply proxied directly to the kubenet CNI driver.
func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) error {
plugins := kcni.ProbeNetworkPlugins(kcni.DefaultNetDir, kcni.DefaultCNIDir)
if len(plugins) == 0 {
return fmt.Errorf("openshift-sdn CNI network plugin config could not be found in %v", kcni.DefaultNetDir)
} else if len(plugins) > 1 {
return fmt.Errorf("multiple CNI network plugins found; only one can be used")
}
node.host = host
node.kubeletCniPlugin = plugins[0]
err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
// Let initial pod updates happen if they need to
glog.V(5).Infof("openshift-sdn CNI plugin initialized")
close(node.kubeletInitReady)
return err
}
func (node *OsdnNode) Name() string {
return kcni.CNIPluginName
}
func (node *OsdnNode) Capabilities() utilsets.Int {
return utilsets.NewInt(knetwork.NET_PLUGIN_CAPABILITY_SHAPING)
}
func (node *OsdnNode) SetUpPod(namespace string, name string, id kubeletTypes.ContainerID, annotations map[string]string) error {
return node.kubeletCniPlugin.SetUpPod(namespace, name, id, annotations)
}
func (node *OsdnNode) TearDownPod(namespace string, name string, id kubeletTypes.ContainerID) error {
return node.kubeletCniPlugin.TearDownPod(namespace, name, id)
}
func (node *OsdnNode) Status() error {
if err := node.IsPodNetworkReady(); err != nil {
return err
}
return node.kubeletCniPlugin.Status()
}
func (node *OsdnNode) GetPodNetworkStatus(namespace string, name string, id kubeletTypes.ContainerID) (*knetwork.PodNetworkStatus, error) {
return node.kubeletCniPlugin.GetPodNetworkStatus(namespace, name, id)
}
func (node *OsdnNode) Event(name string, details map[string]interface{}) {
node.kubeletCniPlugin.Event(name, details)
}