Implement network plugin capabilities hook and shaping capability

Allow network plugins to declare that they handle shaping and that
Kuberenetes should not.  Will be first used by openshift-sdn which
handles shaping through OVS, but this triggers a warning when
kubelet notices the bandwidth annotations.
This commit is contained in:
Dan Williams
2016-03-22 11:43:13 -05:00
parent f1323103db
commit fb97b8cdaa
2 changed files with 33 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ import (
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
utilerrors "k8s.io/kubernetes/pkg/util/errors"
utilexec "k8s.io/kubernetes/pkg/util/exec"
utilsets "k8s.io/kubernetes/pkg/util/sets"
utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
"k8s.io/kubernetes/pkg/util/validation"
)
@@ -40,6 +41,12 @@ const DefaultPluginName = "kubernetes.io/no-op"
const NET_PLUGIN_EVENT_POD_CIDR_CHANGE = "pod-cidr-change"
const NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR = "pod-cidr"
// Plugin capabilities
const (
// Indicates the plugin handles Kubernetes bandwidth shaping annotations internally
NET_PLUGIN_CAPABILITY_SHAPING int = 1
)
// Plugin is an interface to network plugins for the kubelet
type NetworkPlugin interface {
// Init initializes the plugin. This will be called exactly once
@@ -54,6 +61,9 @@ type NetworkPlugin interface {
// for a plugin by name, e.g.
Name() string
// Returns a set of NET_PLUGIN_CAPABILITY_*
Capabilities() utilsets.Int
// SetUpPod is the method called after the infra container of
// the pod has been created but before the other containers of the
// pod are launched.
@@ -166,6 +176,10 @@ func (plugin *NoopNetworkPlugin) Name() string {
return DefaultPluginName
}
func (plugin *NoopNetworkPlugin) Capabilities() utilsets.Int {
return utilsets.NewInt()
}
func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.DockerID) error {
return nil
}