Documentation ¶
Overview ¶
Package ipam provides node-local IPAM calculations: POD IP addresses, VPP-host interconnect and node interconnect IP addresses.
The IP assignment is driven by unique node ID (uint32), that is passed to the IPAM module upon its initialization, together with IPAM configuration (can be specified as IPAMConfig in contiv-agent-cfg ConfigMap in ../../k8s/contiv-vpp.yaml). The contiv-agent on each node in the k8s cluster therefore does its node-local IPAM calculation and assignment itself, the cluster IPAM is therefore distributed between all nodes.
The package calculates and assigns the following IP addresses:
- node-local POD network and individual POD IPs (based on PodSubnetCIDR, PodNetworkPrefixLen and node ID)
- IP subnet for the VPP-to-host Linux stack interconnect (based on VPPHostSubnetCIDR, VPPHostNetworkPrefixLen and node ID)
- IP address of the physical interface used for node interconnect (based on NodeInterconnectCIDR and node ID)
Example:
IPAMConfig: PodSubnetCIDR: "10.1.0.0/16" PodNetworkPrefixLen: 24 VPPHostSubnetCIDR: "172.30.0.0/16" VPPHostNetworkPrefixLen: 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)
Additionally the package provides REST endpoint for getting some of IPAM informations from node on URL GET /contiv/v1/ipam.
Example:
$ curl localhost:9999/contiv/v1/ipam { "nodeId": 1, "nodeName": "vagrant-arch.vagrantup.com", "nodeIP": "192.168.16.1", "podNetwork": "10.1.1.0/24", "vppHostNetwork": "172.30.1.0/24" }
Index ¶
- type Config
- type IPAM
- func (i *IPAM) NextPodIP(podID string) (net.IP, error)
- func (i *IPAM) NodeID() uint32
- func (i *IPAM) NodeIPAddress(nodeID uint32) (net.IP, error)
- func (i *IPAM) NodeIPWithPrefix(nodeID uint32) (*net.IPNet, error)
- func (i *IPAM) NodeInterconnectDHCPEnabled() bool
- func (i *IPAM) OtherNodePodNetwork(nodeID uint32) (*net.IPNet, error)
- func (i *IPAM) OtherNodeVPPHostNetwork(nodeID uint32) (*net.IPNet, error)
- func (i *IPAM) PodGatewayIP() net.IP
- func (i *IPAM) PodNetwork() *net.IPNet
- func (i *IPAM) PodSubnet() *net.IPNet
- func (i *IPAM) ReleasePodIP(podID string) error
- func (i *IPAM) ServiceNetwork() *net.IPNet
- func (i *IPAM) VEthHostEndIP() net.IP
- func (i *IPAM) VEthVPPEndIP() net.IP
- func (i *IPAM) VPPHostNetwork() *net.IPNet
- func (i *IPAM) VPPHostSubnet() *net.IPNet
- func (i *IPAM) VPPIfIPPrefix() *net.IP
- func (i *IPAM) VxlanIPAddress(nodeID uint32) (net.IP, error)
- func (i *IPAM) VxlanIPWithPrefix(nodeID uint32) (*net.IPNet, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { PodIfIPCIDR string `json:"podIfIPCIDR"` // subnet from which individual VPP-side POD interfaces networks are allocated, this is subnet for all PODS within 1 node. PodSubnetCIDR string `json:"podSubnetCIDR"` // subnet from which individual POD networks are allocated, this is subnet for all PODs across all nodes PodNetworkPrefixLen uint8 `json:"podNetworkPrefixLen"` // prefix length of subnet used for all PODs within 1 node (pod network = pod subnet for one 1 node) VPPHostSubnetCIDR string `json:"vppHostSubnetCIDR"` // subnet used across all nodes for VPP to host Linux stack interconnect VPPHostNetworkPrefixLen uint8 `json:"vppHostNetworkPrefixLen"` // prefix length of subnet used for for VPP to host Linux stack interconnect within 1 node (VPPHost network = VPPHost subnet for one 1 node) NodeInterconnectCIDR string `json:"nodeInterconnectCIDR"` // subnet used for for inter-node connections NodeInterconnectDHCP bool `json:"nodeInterconnectDHCP"` // if set to true DHCP is used to acquire IP for the main VPP interface (NodeInterconnectCIDR can be omitted in config) VxlanCIDR string `json:"vxlanCIDR"` // subnet used for for inter-node VXLAN ServiceCIDR string `json:"serviceCIDR"` // subnet used by services ContivCIDR string `json:"contivCIDR"` // subnet from which all subnets (pod/node/vxlan) will be created }
Config represents configuration of the IPAM module.
type IPAM ¶
type IPAM struct {
// contains filtered or unexported fields
}
IPAM represents the basic Contiv IPAM module.
func New ¶
func New(logger logging.Logger, nodeID uint32, nodeName string, config *Config, nodeInterconnectExcludedIPs []net.IP, broker keyval.ProtoBroker) (*IPAM, error)
New returns new IPAM module to be used on the node specified by the nodeID.
func (*IPAM) NextPodIP ¶
NextPodIP returns next available POD IP address and remembers that this IP is meant to be used for the POD with the id <podID>.
func (*IPAM) NodeIPAddress ¶
NodeIPAddress computes IP address of the node based on the provided node ID.
func (*IPAM) NodeIPWithPrefix ¶
NodeIPWithPrefix computes node address with prefix length based on the provided node ID.
func (*IPAM) NodeInterconnectDHCPEnabled ¶
NodeInterconnectDHCPEnabled returns true if DHCP should be configured on the main vpp interface by default.
func (*IPAM) OtherNodePodNetwork ¶
OtherNodePodNetwork returns the POD network of another node identified by nodeID.
func (*IPAM) OtherNodeVPPHostNetwork ¶
OtherNodeVPPHostNetwork returns VPP-host network of another node identified by nodeID.
func (*IPAM) PodGatewayIP ¶
PodGatewayIP returns gateway IP address of the POD network of this node.
func (*IPAM) PodNetwork ¶
PodNetwork returns POD network for the current node (given by nodeID given at IPAM creation).
func (*IPAM) PodSubnet ¶
PodSubnet returns POD subnet ("network_address/prefix_length") that is a base subnet for all PODs of all nodes.
func (*IPAM) ReleasePodIP ¶
ReleasePodIP releases the pod IP address remembered for POD id string, so that it can be reused by the next PODs.
func (*IPAM) ServiceNetwork ¶
ServiceNetwork returns range allocated for services.
func (*IPAM) VEthHostEndIP ¶
VEthHostEndIP provides the IPv4 address of the host-end of the VPP to host interconnect veth pair.
func (*IPAM) VEthVPPEndIP ¶
VEthVPPEndIP provides the IPv4 address of the VPP-end of the VPP to host interconnect veth pair.
func (*IPAM) VPPHostNetwork ¶
VPPHostNetwork returns vswitch network used to connect VPP to its host Linux Stack.
func (*IPAM) VPPHostSubnet ¶
VPPHostSubnet returns vswitch base subnet used to connect VPP to its host Linux Stack on all nodes.
func (*IPAM) VPPIfIPPrefix ¶
VPPIfIPPrefix returns VPP-side interface IP address prefix.
func (*IPAM) VxlanIPAddress ¶
VxlanIPAddress computes IP address of the VXLAN interface based on the provided node ID.