Documentation ¶
Overview ¶
Package ipam provides node-local IPAM calculations: POD IP addresses, VPP-host interconnect and node interconnect IP addresses.
The configuration for IPAM is retrieved from the ContivConf plugin.
Single IPAM instance is responsible for all node-local allocations. Between nodes, however, IPAMs do not communicate with each other, instead, the unique node ID (uint32), retrieved from the nodesync plugin upon the first resync, is used to avoid inter-node collisions.
The plugin calculates and assigns the following IP addresses:
- node-local POD network and individual POD IPs (based on podSubnetCIDR, podSubnetOneNodePrefixLen and node ID)
- IP subnet for the VPP-to-host Linux stack interconnect (based on vppHostSubnetCIDR, vppHostSubnetOneNodePrefixLen and node ID)
- IP address of the physical interface used for node interconnect (based on nodeInterconnectCIDR and node ID)
Example (configuration from contiv.conf processed by ContivConf plugin):
ipamConfig: podSubnetCIDR: "10.1.0.0/16" podSubnetOneNodePrefixLen: 24 vppHostSubnetCIDR: "172.30.0.0/16" vppHostSubnetOneNodePrefixLen: 24 nodeInterconnectCIDR: "192.168.16.0/24" Assigned node ID: 5 Calculated POD IPs: 10.1.5.2 - 10.1.5.254 (/24) Calculated VPP-host interconnect IPs: 172.30.5.1, 172.30.5.2 (/24) Calculated Node Interconnect IP: 192.168.16.5 (/24)
Index ¶
- Variables
- type API
- type Deps
- type IPAM
- func (i *IPAM) AllocatePodIP(podID podmodel.ID, ipamType string, ipamData string) (net.IP, error)
- func (i *IPAM) Close() error
- func (i *IPAM) GetPodIP(podID podmodel.ID) *net.IPNet
- func (i *IPAM) HandlesEvent(event controller.Event) bool
- func (i *IPAM) HostInterconnectIPInLinux() net.IP
- func (i *IPAM) HostInterconnectIPInVPP() net.IP
- func (i *IPAM) HostInterconnectSubnetAllNodes() *net.IPNet
- func (i *IPAM) HostInterconnectSubnetOtherNode(nodeID uint32) (*net.IPNet, error)
- func (i *IPAM) HostInterconnectSubnetThisNode() *net.IPNet
- func (i *IPAM) Init() (err error)
- func (i *IPAM) NatLoopbackIP() net.IP
- func (i *IPAM) NodeIPAddress(nodeID uint32) (net.IP, *net.IPNet, error)
- func (i *IPAM) PodGatewayIP() net.IP
- func (i *IPAM) PodSubnetAllNodes() *net.IPNet
- func (i *IPAM) PodSubnetOtherNode(nodeID uint32) (*net.IPNet, error)
- func (i *IPAM) PodSubnetThisNode() *net.IPNet
- func (i *IPAM) ReleasePodIP(podID podmodel.ID) error
- func (i *IPAM) Resync(event controller.Event, kubeStateData controller.KubeStateData, ...) (err error)
- func (i *IPAM) Revert(event controller.Event) error
- func (i *IPAM) ServiceNetwork() *net.IPNet
- func (i *IPAM) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
- func (i *IPAM) VxlanIPAddress(nodeID uint32) (net.IP, *net.IPNet, error)
- type Option
- type PodCIDRChange
Constants ¶
This section is empty.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of IPAM plugin.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // NodeIPAddress computes IP address of the node based on the provided node ID. NodeIPAddress(nodeID uint32) (net.IP, *net.IPNet, error) // VxlanIPAddress computes IP address of the VXLAN interface based on the provided // node ID. VxlanIPAddress(nodeID uint32) (net.IP, *net.IPNet, error) // HostInterconnectIPInVPP provides the IPv4 address for the VPP-end of the VPP-to-host // interconnect. HostInterconnectIPInVPP() net.IP // HostInterconnectIPInLinux provides the IPv4 address of the host(Linux)-end // of the VPP-to-host interconnect. HostInterconnectIPInLinux() net.IP // HostInterconnectSubnetThisNode returns vswitch network used to connect // VPP to its host Linux Stack on this node. HostInterconnectSubnetThisNode() *net.IPNet // HostInterconnectSubnetAllNodes returns vswitch base subnet used to connect // VPP to its host Linux Stack on all nodes. HostInterconnectSubnetAllNodes() *net.IPNet // HostInterconnectSubnetOtherNode returns VPP-host network of another node // identified by nodeID. HostInterconnectSubnetOtherNode(nodeID uint32) (*net.IPNet, error) // PodSubnetAllNodes returns POD subnet that is a base subnet for all PODs // of all nodes. PodSubnetAllNodes() *net.IPNet // PodSubnetThisNode returns POD network for the current node // (given by nodeID allocated for this node). PodSubnetThisNode() *net.IPNet // PodSubnetOtherNode returns the POD network of another node identified by nodeID. PodSubnetOtherNode(nodeID uint32) (*net.IPNet, error) // ServiceNetwork returns range allocated for services. ServiceNetwork() *net.IPNet // PodGatewayIP returns gateway IP address of the POD subnet of this node. PodGatewayIP() net.IP // NatLoopbackIP returns the IP address of a virtual loopback, used to route // traffic between clients and services via VPP even if the source and destination // are the same IP addresses and would otherwise be routed locally. NatLoopbackIP() net.IP // AllocatePodIP tries to allocate IP address for the given pod. AllocatePodIP(podID podmodel.ID, ipamType string, ipamData string) (net.IP, error) // GetPodIP returns the allocated pod IP, together with the mask. // Returns nil if the pod does not have allocated IP address. GetPodIP(podID podmodel.ID) *net.IPNet // ReleasePodIP releases the pod IP address making it available for new PODs. ReleasePodIP(podID podmodel.ID) error }
API defines methods provided by IPAM for use by other plugins.
type Deps ¶
type Deps struct { infra.PluginDeps NodeSync nodesync.API ContivConf contivconf.API ServiceLabel servicelabel.ReaderAPI EventLoop controller.EventLoop }
Deps lists dependencies of the IPAM plugin.
type IPAM ¶
type IPAM struct { Deps // contains filtered or unexported fields }
IPAM plugin implements IP address allocation for Contiv.
func (*IPAM) AllocatePodIP ¶
AllocatePodIP tries to allocate IP address for the given pod.
func (*IPAM) GetPodIP ¶
GetPodIP returns the allocated pod IP, together with the mask. Returns nil if the pod does not have allocated IP address.
func (*IPAM) HandlesEvent ¶
func (i *IPAM) HandlesEvent(event controller.Event) bool
HandlesEvent selects any Resync event.
- any Resync event
- NodeUpdate for the current node if external IPAM is in use (may trigger PodCIDRChange)
func (*IPAM) HostInterconnectIPInLinux ¶
HostInterconnectIPInLinux provides the IPv4 address of the host(Linux)-end of the VPP to host interconnect.
func (*IPAM) HostInterconnectIPInVPP ¶
HostInterconnectIPInVPP provides the IPv4 address for the VPP-end of the VPP-to-host interconnect.
func (*IPAM) HostInterconnectSubnetAllNodes ¶
HostInterconnectSubnetAllNodes returns vswitch base subnet used to connect VPP to its host Linux Stack on all nodes.
func (*IPAM) HostInterconnectSubnetOtherNode ¶
HostInterconnectSubnetOtherNode returns VPP-host network of another node identified by nodeID.
func (*IPAM) HostInterconnectSubnetThisNode ¶
HostInterconnectSubnetThisNode returns vswitch network used to connect VPP to its host Linux Stack on this node.
func (*IPAM) NatLoopbackIP ¶
NatLoopbackIP returns the IP address of a virtual loopback, used to route traffic between clients and services via VPP even if the source and destination are the same IP addresses and would otherwise be routed locally.
func (*IPAM) NodeIPAddress ¶
NodeIPAddress computes IP address of the node based on the provided node ID.
func (*IPAM) PodGatewayIP ¶
PodGatewayIP returns gateway IP address of the POD subnet of this node.
func (*IPAM) PodSubnetAllNodes ¶
PodSubnetAllNodes returns POD subnet that is a base subnet for all PODs of all nodes.
func (*IPAM) PodSubnetOtherNode ¶
PodSubnetOtherNode returns the POD network of another node identified by nodeID.
func (*IPAM) PodSubnetThisNode ¶
PodSubnetThisNode returns POD network for the current node (given by nodeID given at IPAM creation).
func (*IPAM) ReleasePodIP ¶
ReleasePodIP releases the pod IP address making it available for new PODs.
func (*IPAM) Resync ¶
func (i *IPAM) Resync(event controller.Event, kubeStateData controller.KubeStateData, resyncCount int, txn controller.ResyncOperations) (err error)
Resync resynchronizes IPAM against the configuration and Kubernetes state data. A set of already allocated pod IPs is updated.
func (*IPAM) Revert ¶
func (i *IPAM) Revert(event controller.Event) error
Revert is NOOP - never called.
func (*IPAM) ServiceNetwork ¶
ServiceNetwork returns range allocated for services.
func (*IPAM) Update ¶
func (i *IPAM) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
Update handles NodeUpdate event in case that external IPAM is in use.
type Option ¶
type Option func(*IPAM)
Option is a function that acts on a Plugin to inject Dependencies or configuration
type PodCIDRChange ¶
PodCIDRChange is triggered when CIDR for PODs on the current node changes.
func (*PodCIDRChange) GetName ¶
func (ev *PodCIDRChange) GetName() string
GetName returns name of the PodCIDRChange event.
func (*PodCIDRChange) IsBlocking ¶
func (ev *PodCIDRChange) IsBlocking() bool
IsBlocking returns false.
func (*PodCIDRChange) Method ¶
func (ev *PodCIDRChange) Method() controller.EventMethodType
Method is UpstreamResync.
func (*PodCIDRChange) String ¶
func (ev *PodCIDRChange) String() string
String describes PodCIDRChange event.