Documentation
¶
Index ¶
- Constants
- func GetPodIPs(execer utilexec.Interface, nsenterPath, netnsPath, interfaceName string) ([]net.IP, error)
- type Host
- 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 config.ContainerID) (*PodNetworkStatus, error)
- func (plugin *NoopNetworkPlugin) Init(host Host, hairpinMode config.HairpinMode, nonMasqueradeCIDR string, mtu int) error
- func (plugin *NoopNetworkPlugin) Name() string
- func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id config.ContainerID, ...) error
- func (plugin *NoopNetworkPlugin) Status() error
- func (plugin *NoopNetworkPlugin) TearDownPod(namespace string, name string, id config.ContainerID) error
- type NoopPortMappingGetter
- type PluginManager
- func (pm *PluginManager) Event(name string, details map[string]interface{})
- func (pm *PluginManager) GetPodNetworkStatus(podNamespace, podName string, id config.ContainerID) (*PodNetworkStatus, error)
- func (pm *PluginManager) PluginName() string
- func (pm *PluginManager) SetUpPod(podNamespace, podName string, id config.ContainerID, ...) error
- func (pm *PluginManager) Status() error
- func (pm *PluginManager) TearDownPod(podNamespace, podName string, id config.ContainerID) error
- type PodNetworkStatus
- type PortMappingGetter
Constants ¶
const ( DefaultPluginName = "kubernetes.io/no-op" // Called when the node's Pod CIDR is known when using the // controller manager's --allocate-node-cidrs=true option NET_PLUGIN_EVENT_POD_CIDR_CHANGE = "pod-cidr-change" NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR = "pod-cidr" )
const CNITimeoutSec = 220
CNITimeoutSec is set to be slightly less than 240sec/4mins, which is the default backend runtime request timeout.
const DefaultInterfaceName = "eth0"
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 ¶
Types ¶
type Host ¶
type Host interface {
// NamespaceGetter is a getter for sandbox namespace information.
NamespaceGetter
// PortMappingGetter is a getter for sandbox port mapping information.
PortMappingGetter
}
Host is an interface that plugins can use to access the kubelet. 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 and port mapping information , which they can do directly through the embedded interfaces.
type NamespaceGetter ¶
type NamespaceGetter interface {
// GetNetNS returns network namespace information for the given containerID.
// Runtimes should *never* return an empty namespace and nil error for
// a container; if error is nil then the namespace string must be valid.
GetNetNS(containerID string) (string, error)
}
NamespaceGetter is an interface to retrieve namespace information for a given podSandboxID. 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 config.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.
SetUpPod(
namespace string,
name string,
podSandboxID config.ContainerID,
annotations, options map[string]string,
) error
// TearDownPod is the method called before a pod's infra container will be deleted
TearDownPod(namespace string, name string, podSandboxID config.ContainerID) error
// GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the container
GetPodNetworkStatus(
namespace string,
name string,
podSandboxID config.ContainerID,
) (*PodNetworkStatus, error)
// Status returns error if the network plugin is in error state
Status() error
}
NetworkPlugin is an interface to network plugins for the kubelet
func InitNetworkPlugin ¶
func InitNetworkPlugin( plugins []NetworkPlugin, networkPluginName string, host Host, hairpinMode config.HairpinMode, nonMasqueradeCIDR string, mtu int, ) (NetworkPlugin, error)
InitNetworkPlugin inits the plugin that matches networkPluginName. Plugins must have unique names.
type NoopNetworkPlugin ¶
type NoopNetworkPlugin struct {
Sysctl utilsysctl.Interface
}
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 config.ContainerID, ) (*PodNetworkStatus, error)
func (*NoopNetworkPlugin) Init ¶
func (plugin *NoopNetworkPlugin) Init( host Host, hairpinMode config.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 config.ContainerID, annotations, options map[string]string, ) error
func (*NoopNetworkPlugin) Status ¶
func (plugin *NoopNetworkPlugin) Status() error
func (*NoopNetworkPlugin) TearDownPod ¶
func (plugin *NoopNetworkPlugin) TearDownPod( namespace string, name string, id config.ContainerID, ) error
type NoopPortMappingGetter ¶
type NoopPortMappingGetter struct{}
func (*NoopPortMappingGetter) GetPodPortMappings ¶
func (*NoopPortMappingGetter) GetPodPortMappings( containerID string, ) ([]*hostport.PortMapping, error)
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
The PluginManager wraps a kubelet network plugin and provides synchronization for a given pod's network operations. Each pod's setup/teardown/status operations are synchronized against each other, but network operations of other pods can proceed in parallel.
func NewPluginManager ¶
func NewPluginManager(plugin NetworkPlugin) *PluginManager
func (*PluginManager) Event ¶
func (pm *PluginManager) Event(name string, details map[string]interface{})
func (*PluginManager) GetPodNetworkStatus ¶
func (pm *PluginManager) GetPodNetworkStatus( podNamespace, podName string, id config.ContainerID, ) (*PodNetworkStatus, error)
func (*PluginManager) PluginName ¶
func (pm *PluginManager) PluginName() string
func (*PluginManager) SetUpPod ¶
func (pm *PluginManager) SetUpPod( podNamespace, podName string, id config.ContainerID, annotations, options map[string]string, ) error
func (*PluginManager) Status ¶
func (pm *PluginManager) Status() error
func (*PluginManager) TearDownPod ¶
func (pm *PluginManager) TearDownPod( podNamespace, podName string, id config.ContainerID, ) error
type PodNetworkStatus ¶
type PodNetworkStatus struct {
metav1.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"`
// IPs is the list of IPs assigned to Pod. IPs[0] == IP. The rest of the list is additional IPs
IPs []net.IP `json:"ips" description:"list of additional ips (inclusive of IP) assigned to pod"`
}
PodNetworkStatus stores the network status of a pod (currently just the primary IP address) This struct represents version "v1beta1"
type PortMappingGetter ¶
type PortMappingGetter interface {
// GetPodPortMappings returns sandbox port mappings information.
GetPodPortMappings(containerID string) ([]*hostport.PortMapping, error)
}
PortMappingGetter is an interface to retrieve port mapping information for a given podSandboxID. Typically implemented by runtime shims that are closely coupled to CNI plugin wrappers like kubenet.