Documentation ¶
Index ¶
- Constants
- func GetPodIP(execer utilexec.Interface, nsenterPath, netnsPath, interfaceName string) (net.IP, error)
- func UnescapePluginName(in string) string
- type Host
- type LegacyHost
- type NamespaceGetter
- type NetworkPlugin
- type NoopNetworkPlugin
- func (plugin *NoopNetworkPlugin) Capabilities() utilsets.Int
- func (plugin *NoopNetworkPlugin) Event(name string, details map[string]interface{})
- func (plugin *NoopNetworkPlugin) GetPodNetworkStatus(namespace string, name string, id kubecontainer.ContainerID) (*PodNetworkStatus, error)
- func (plugin *NoopNetworkPlugin) Init(host Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, ...) error
- func (plugin *NoopNetworkPlugin) Name() string
- func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.ContainerID) error
- func (plugin *NoopNetworkPlugin) Status() error
- func (plugin *NoopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.ContainerID) error
- type PodNetworkStatus
Constants ¶
const DefaultInterfaceName = "eth0"
TODO: Consider making this value configurable.
const DefaultPluginName = "kubernetes.io/no-op"
const ( // Indicates the plugin handles Kubernetes bandwidth shaping annotations internally NET_PLUGIN_CAPABILITY_SHAPING int = 1 )
Plugin capabilities
const NET_PLUGIN_EVENT_POD_CIDR_CHANGE = "pod-cidr-change"
Called when the node's Pod CIDR is known when using the controller manager's --allocate-node-cidrs=true option
const NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR = "pod-cidr"
const UseDefaultMTU = 0
UseDefaultMTU is a marker value that indicates the plugin should determine its own MTU It is the zero value, so a non-initialized value will mean "UseDefault"
Variables ¶
This section is empty.
Functions ¶
func GetPodIP ¶
func GetPodIP(execer utilexec.Interface, nsenterPath, netnsPath, interfaceName string) (net.IP, error)
GetPodIP gets the IP of the pod by inspecting the network info inside the pod's network namespace.
func UnescapePluginName ¶
Types ¶
type Host ¶
type Host interface { // NamespaceGetter is a getter for sandbox namespace information. // It's the only part of this interface that isn't currently deprecated. NamespaceGetter // LegacyHost contains methods that trap back into the Kubelet. Dependence // *do not* add more dependencies in this interface. In a post-cri world, // network plugins will be invoked by the runtime shim, and should only // require NamespaceGetter. LegacyHost }
Host is an interface that plugins can use to access the kubelet. TODO(#35457): get rid of this backchannel to the kubelet. The scope of the back channel is restricted to host-ports/testing, and restricted to kubenet. No other network plugin wrapper needs it. Other plugins only require a way to access namespace information, which they can do directly through the embedded NamespaceGetter.
type LegacyHost ¶
type LegacyHost interface { // Get the pod structure by its name, namespace // Only used for hostport management and bw shaping GetPodByName(namespace, name string) (*api.Pod, bool) // GetKubeClient returns a client interface // Only used in testing GetKubeClient() clientset.Interface // GetContainerRuntime returns the container runtime that implements the containers (e.g. docker/rkt) // Only used for hostport management GetRuntime() kubecontainer.Runtime // SupportsLegacyFeaturs returns true if this host can support hostports // and bandwidth shaping. Both will either get added to CNI or dropped, // so differnt implementations can choose to ignore them. SupportsLegacyFeatures() bool }
LegacyHost implements the methods required by network plugins that were directly invoked by the kubelet. Implementations of this interface that do not wish to support these features can simply return false to SupportsLegacyFeatures.
type NamespaceGetter ¶
type NamespaceGetter interface { // GetNetNS returns network namespace information for the given containerID. GetNetNS(containerID string) (string, error) }
NamespaceGetter is an interface to retrieve namespace information for a given sandboxID. Typically implemented by runtime shims that are closely coupled to CNI plugin wrappers like kubenet.
type NetworkPlugin ¶
type NetworkPlugin interface { // Init initializes the plugin. This will be called exactly once // before any other methods are called. Init(host Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) error // Called on various events like: // NET_PLUGIN_EVENT_POD_CIDR_CHANGE Event(name string, details map[string]interface{}) // Name returns the plugin's name. This will be used when searching // 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. // TODO: rename podInfraContainerID to sandboxID SetUpPod(namespace string, name string, podInfraContainerID kubecontainer.ContainerID) error // TearDownPod is the method called before a pod's infra container will be deleted // TODO: rename podInfraContainerID to sandboxID TearDownPod(namespace string, name string, podInfraContainerID kubecontainer.ContainerID) error // Status is the method called to obtain the ipv4 or ipv6 addresses of the container // TODO: rename podInfraContainerID to sandboxID GetPodNetworkStatus(namespace string, name string, podInfraContainerID kubecontainer.ContainerID) (*PodNetworkStatus, error) // NetworkStatus returns error if the network plugin is in error state Status() error }
Plugin is an interface to network plugins for the kubelet
func InitNetworkPlugin ¶
func InitNetworkPlugin(plugins []NetworkPlugin, networkPluginName string, host Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) (NetworkPlugin, error)
InitNetworkPlugin inits the plugin that matches networkPluginName. Plugins must have unique names.
type NoopNetworkPlugin ¶
type NoopNetworkPlugin struct { }
func (*NoopNetworkPlugin) Capabilities ¶
func (plugin *NoopNetworkPlugin) Capabilities() utilsets.Int
func (*NoopNetworkPlugin) Event ¶
func (plugin *NoopNetworkPlugin) Event(name string, details map[string]interface{})
func (*NoopNetworkPlugin) GetPodNetworkStatus ¶
func (plugin *NoopNetworkPlugin) GetPodNetworkStatus(namespace string, name string, id kubecontainer.ContainerID) (*PodNetworkStatus, error)
func (*NoopNetworkPlugin) Init ¶
func (plugin *NoopNetworkPlugin) Init(host Host, hairpinMode componentconfig.HairpinMode, nonMasqueradeCIDR string, mtu int) error
func (*NoopNetworkPlugin) Name ¶
func (plugin *NoopNetworkPlugin) Name() string
func (*NoopNetworkPlugin) SetUpPod ¶
func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.ContainerID) error
func (*NoopNetworkPlugin) Status ¶
func (plugin *NoopNetworkPlugin) Status() error
func (*NoopNetworkPlugin) TearDownPod ¶
func (plugin *NoopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.ContainerID) error
type PodNetworkStatus ¶
type PodNetworkStatus struct { unversioned.TypeMeta `json:",inline"` // IP is the primary ipv4/ipv6 address of the pod. Among other things it is the address that - // - kube expects to be reachable across the cluster // - service endpoints are constructed with // - will be reported in the PodStatus.PodIP field (will override the IP reported by docker) IP net.IP `json:"ip" description:"Primary IP address of the pod"` }
PodNetworkStatus stores the network status of a pod (currently just the primary IP address) This struct represents version "v1beta1"
Directories ¶
Path | Synopsis |
---|---|
testing
mock_cni is a mock of the `libcni.CNI` interface.
|
mock_cni is a mock of the `libcni.CNI` interface. |
Package exec scans and loads networking plugins that are installed under /usr/libexec/kubernetes/kubelet-plugins/net/exec/ The layout convention for a plugin is: plugin-name/ (plugins have to be directories first) plugin-name/plugin-name (executable that will be called out, see Vendoring Note for more nuances) plugin-name/<other-files> where, 'executable' has the following requirements: - should have exec permissions - should give non-zero exit code on failure, and zero on success - the arguments will be <action> <pod_namespace> <pod_name> <docker_id_of_infra_container> whereupon, <action> will be one of: - init, called when the kubelet loads the plugin - setup, called after the infra container of a pod is created, but before other containers of the pod are created - teardown, called before the pod infra container is killed - status, called at regular intervals and is supposed to return a json formatted output indicating the pod's IPAddress(v4/v6).
|
Package exec scans and loads networking plugins that are installed under /usr/libexec/kubernetes/kubelet-plugins/net/exec/ The layout convention for a plugin is: plugin-name/ (plugins have to be directories first) plugin-name/plugin-name (executable that will be called out, see Vendoring Note for more nuances) plugin-name/<other-files> where, 'executable' has the following requirements: - should have exec permissions - should give non-zero exit code on failure, and zero on success - the arguments will be <action> <pod_namespace> <pod_name> <docker_id_of_infra_container> whereupon, <action> will be one of: - init, called when the kubelet loads the plugin - setup, called after the infra container of a pod is created, but before other containers of the pod are created - teardown, called before the pod infra container is killed - status, called at regular intervals and is supposed to return a json formatted output indicating the pod's IPAddress(v4/v6). |