ipam

package
v2.0.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

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

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

func (i *IPAM) NextPodIP(podID string) (net.IP, error)

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) NodeID

func (i *IPAM) NodeID() uint32

NodeID returns unique host ID used to calculate the IP addresses.

func (*IPAM) NodeIPAddress

func (i *IPAM) NodeIPAddress(nodeID uint32) (net.IP, error)

NodeIPAddress computes IP address of the node based on the provided node ID.

func (*IPAM) NodeIPWithPrefix

func (i *IPAM) NodeIPWithPrefix(nodeID uint32) (*net.IPNet, error)

NodeIPWithPrefix computes node address with prefix length based on the provided node ID.

func (*IPAM) NodeInterconnectDHCPEnabled

func (i *IPAM) NodeInterconnectDHCPEnabled() bool

NodeInterconnectDHCPEnabled returns true if DHCP should be configured on the main vpp interface by default.

func (*IPAM) OtherNodePodNetwork

func (i *IPAM) OtherNodePodNetwork(nodeID uint32) (*net.IPNet, error)

OtherNodePodNetwork returns the POD network of another node identified by nodeID.

func (*IPAM) OtherNodeVPPHostNetwork

func (i *IPAM) OtherNodeVPPHostNetwork(nodeID uint32) (*net.IPNet, error)

OtherNodeVPPHostNetwork returns VPP-host network of another node identified by nodeID.

func (*IPAM) PodGatewayIP

func (i *IPAM) PodGatewayIP() net.IP

PodGatewayIP returns gateway IP address of the POD network of this node.

func (*IPAM) PodNetwork

func (i *IPAM) PodNetwork() *net.IPNet

PodNetwork returns POD network for the current node (given by nodeID given at IPAM creation).

func (*IPAM) PodSubnet

func (i *IPAM) PodSubnet() *net.IPNet

PodSubnet returns POD subnet ("network_address/prefix_length") that is a base subnet for all PODs of all nodes.

func (*IPAM) ReleasePodIP

func (i *IPAM) ReleasePodIP(podID string) error

ReleasePodIP releases the pod IP address remembered for POD id string, so that it can be reused by the next PODs.

func (*IPAM) ServiceNetwork

func (i *IPAM) ServiceNetwork() *net.IPNet

ServiceNetwork returns range allocated for services.

func (*IPAM) VEthHostEndIP

func (i *IPAM) VEthHostEndIP() net.IP

VEthHostEndIP provides the IPv4 address of the host-end of the VPP to host interconnect veth pair.

func (*IPAM) VEthVPPEndIP

func (i *IPAM) VEthVPPEndIP() net.IP

VEthVPPEndIP provides the IPv4 address of the VPP-end of the VPP to host interconnect veth pair.

func (*IPAM) VPPHostNetwork

func (i *IPAM) VPPHostNetwork() *net.IPNet

VPPHostNetwork returns vswitch network used to connect VPP to its host Linux Stack.

func (*IPAM) VPPHostSubnet

func (i *IPAM) VPPHostSubnet() *net.IPNet

VPPHostSubnet returns vswitch base subnet used to connect VPP to its host Linux Stack on all nodes.

func (*IPAM) VPPIfIPPrefix

func (i *IPAM) VPPIfIPPrefix() *net.IP

VPPIfIPPrefix returns VPP-side interface IP address prefix.

func (*IPAM) VxlanIPAddress

func (i *IPAM) VxlanIPAddress(nodeID uint32) (net.IP, error)

VxlanIPAddress computes IP address of the VXLAN interface based on the provided node ID.

func (*IPAM) VxlanIPWithPrefix

func (i *IPAM) VxlanIPWithPrefix(nodeID uint32) (*net.IPNet, error)

VxlanIPWithPrefix computes VXLAN interface address with prefix length based on the provided node ID.

Directories

Path Synopsis
Package model is a generated protocol buffer package.
Package model is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL