contivconf

package
Version: v3.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 25 Imported by: 24

Documentation

Index

Constants

View Source
const (
	// VXLANTransport is config value representing usage of VXLAN in node-to-node communication
	VXLANTransport = "vxlan"
	// SRv6Transport is config value representing usage of SRv6 in node-to-node communication
	SRv6Transport = "srv6"
	// NoOverlayTransport is config value representing usage of other (not above mentioned)
	// techniques in node-to-node communication (routing tables/...)
	NoOverlayTransport = "nooverlay"
)

NodeToNodeTransport configuration values enum

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of ContivConf.

Functions

This section is empty.

Types

type API

type API interface {
	// InSTNMode returns true if the agent operates in the STN mode
	// (node has single interface stolen from the host stack for VPP).
	// STN configuration can be obtained via GetSTNConfig().
	InSTNMode() bool

	// UseDHCP returns true when the main VPP interface should be configured
	// with DHCP instead of static IP addresses.
	// With DHCP, GetMainInterfaceStaticIPs() and GetStaticDefaultGW() should
	// be ignored.
	UseDHCP() bool

	// EnablePacketTrace returns true if packets flowing through VPP should be
	// captured for later inspection.
	EnablePacketTrace() bool

	// GetMainInterfaceName returns the logical name of the VPP physical interface
	// to use for connecting the node with the cluster.
	// If empty, a loopback interface should be configured instead.
	GetMainInterfaceName() string

	// GetMainInterfaceConfiguredIPs returns the list of IP addresses configured
	// to be assigned to the main interface. Ignore if DHCP is enabled.
	// The function may return an empty list, then it is necessary to request
	// node IP from IPAM.
	GetMainInterfaceConfiguredIPs() IPsWithNetworks

	// GetOtherVPPInterfaces returns configuration to apply for non-main physical
	// VPP interfaces.
	GetOtherVPPInterfaces() OtherInterfaces

	// GetStaticDefaultGW returns the IP address of the default gateway.
	// Ignore if DHCP is enabled (in that case it is provided by the DHCP server)
	GetStaticDefaultGW() net.IP

	// NatExternalTraffic returns true when it is required to S-NAT traffic
	// leaving the node and heading out from the cluster.
	NatExternalTraffic() bool

	// GetIPAMConfig returns configuration to be used by the IPAM module.
	GetIPAMConfig() *IPAMConfig

	// GetIPAMConfigForJSON returns IPAM configuration in format suitable
	// for marshalling to JSON (subnets not converted to net.IPNet + defined
	// JSON flag for every option).
	GetIPAMConfigForJSON() *config.IPAMConfig

	// GetInterfaceConfig returns configuration related to VPP interfaces.
	GetInterfaceConfig() *config.InterfaceConfig

	// GetRoutingConfig returns configuration related to IP routing.
	GetRoutingConfig() *config.RoutingConfig

	// GetIPNeighborScanConfig returns configuration related to IP Neighbor
	// scanning.
	GetIPNeighborScanConfig() *config.IPNeighborScanConfig

	// GetSTNConfig returns configuration related to STN feature.
	// Use the method only in the STN mode - i.e. when InSTNMode() returns true.
	GetSTNConfig() *STNConfig

	// UseVmxnet3 returns true if vmxnet3 driver should be used for access to physical
	// interfaces instead of DPDK.
	// Vmxnet3 configuration can be obtained using GetVmxnet3Config()
	UseVmxnet3() bool

	// GetVmxnet3Config returns configuration related to vmxnet3 feature.
	// Use the method only if vmxnet3 is in use - i.e. when UseVmxnet3() returns true.
	GetVmxnet3Config() (*Vmxnet3Config, error)
}

API defines methods provided by ContivConf for use by other plugins.

type ContivAgentDeps

type ContivAgentDeps struct {
	EventLoop controller.EventLoop
}

ContivAgentDeps lists dependencies of the plugin for use in contiv-agent.

type ContivConf

type ContivConf struct {
	Deps
	// contains filtered or unexported fields
}

ContivConf plugins simplifies the Contiv configuration processing for other plugins. Contiv has multiple sources of configuration:

- configuration file, further split between the global options and node-specific
  sections
- NodeConfig CRD
- STN daemon
- implicit values determined on run-time - e.g. use the first interface by name/index

ContivConf reads all the sources of the configuration and for each option determines the right value based on priorities.

func NewPlugin

func NewPlugin(opts ...Option) *ContivConf

NewPlugin creates a new Plugin with the provides Options.

func (*ContivConf) Close

func (c *ContivConf) Close() error

Close is NOOP.

func (*ContivConf) EnablePacketTrace

func (c *ContivConf) EnablePacketTrace() bool

EnablePacketTrace returns true if packets flowing through VPP should be captured for later inspection.

func (*ContivConf) GetIPAMConfig

func (c *ContivConf) GetIPAMConfig() *IPAMConfig

GetIPAMConfig returns configuration to be used by the IPAM module.

func (*ContivConf) GetIPAMConfigForJSON

func (c *ContivConf) GetIPAMConfigForJSON() *config.IPAMConfig

GetIPAMConfigForJSON returns IPAM configuration in format suitable for marshalling to JSON (subnets not converted to net.IPNet + defined JSON flag for every option).

func (*ContivConf) GetIPNeighborScanConfig

func (c *ContivConf) GetIPNeighborScanConfig() *config.IPNeighborScanConfig

GetIPNeighborScanConfig returns configuration related to IP Neighbor scanning.

func (*ContivConf) GetInterfaceConfig

func (c *ContivConf) GetInterfaceConfig() *config.InterfaceConfig

GetInterfaceConfig returns configuration related to VPP interfaces.

func (*ContivConf) GetMainInterfaceConfiguredIPs

func (c *ContivConf) GetMainInterfaceConfiguredIPs() IPsWithNetworks

GetMainInterfaceConfiguredIPs returns the list of IP addresses configured to be assigned to the main interface. Ignore if DHCP is enabled. The function may return an empty list, then it is necessary to request node IP from IPAM.

func (*ContivConf) GetMainInterfaceName

func (c *ContivConf) GetMainInterfaceName() string

GetMainInterfaceName returns the logical name of the VPP physical interface to use for connecting the node with the cluster.

func (*ContivConf) GetOtherVPPInterfaces

func (c *ContivConf) GetOtherVPPInterfaces() OtherInterfaces

GetOtherVPPInterfaces returns configuration to apply for non-main physical VPP interfaces.

func (*ContivConf) GetRoutingConfig

func (c *ContivConf) GetRoutingConfig() *config.RoutingConfig

GetRoutingConfig returns configuration related to IP routing.

func (*ContivConf) GetSTNConfig

func (c *ContivConf) GetSTNConfig() *STNConfig

GetSTNConfig returns configuration related to STN feature. Use the method only in the STN mode - i.e. when InSTNMode() returns true.

func (*ContivConf) GetStaticDefaultGW

func (c *ContivConf) GetStaticDefaultGW() net.IP

GetStaticDefaultGW returns the IP address of the default gateway. Ignore if DHCP is enabled (in that case it is provided by the DHCP server)

func (*ContivConf) GetVmxnet3Config

func (c *ContivConf) GetVmxnet3Config() (*Vmxnet3Config, error)

GetVmxnet3Config returns configuration related to vmxnet3 feature. Use the method only if vmxnet3 is in use - i.e. when UseVmxnet3() returns true.

func (*ContivConf) HandlesEvent

func (c *ContivConf) HandlesEvent(event controller.Event) bool

HandlesEvent selects:

- any Resync event
- KubeStateChange for CRD node-specific config of this node

func (*ContivConf) InSTNMode

func (c *ContivConf) InSTNMode() bool

InSTNMode returns true if the agent operates in the STN mode (node has single interface stolen from the host stack for VPP). STN configuration can be obtained via GetSTNConfig().

func (*ContivConf) Init

func (c *ContivConf) Init() (err error)

Init does several operations:

- loads Contiv configuration file
- parses IP subnets configured for IPAM
- for contiv-init:
     * if crdNodeConfigurationDisabled=false, waits for NodeConfig CRD to be available
     * if stealFirstNIC=true, lists Linux interfaces to obtain the first one

func (*ContivConf) NatExternalTraffic

func (c *ContivConf) NatExternalTraffic() bool

NatExternalTraffic returns true when it is required to S-NAT traffic leaving the node and heading out from the cluster.

func (*ContivConf) Resync

func (c *ContivConf) Resync(event controller.Event, kubeStateData controller.KubeStateData,
	resyncCount int, txn controller.ResyncOperations) (err error)

Resync reloads the configuration - configuration file and STN configuration, however, are loaded only once during the startup resync.

func (*ContivConf) Revert

func (c *ContivConf) Revert(event controller.Event) error

Revert is NOOP.

func (*ContivConf) Update

func (c *ContivConf) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string,
	err error)

Update is called for KubeStateChange for CRD node-specific config of this node.

func (*ContivConf) UseDHCP

func (c *ContivConf) UseDHCP() bool

UseDHCP returns true when the main VPP interface should be configured with DHCP instead of static IP addresses. With DHCP, GetMainInterfaceStaticIPs() and GetStaticDefaultGW() should be ignored.

func (*ContivConf) UseVmxnet3

func (c *ContivConf) UseVmxnet3() bool

UseVmxnet3 returns true if vmxnet3 driver should be used for access to physical interfaces instead of DPDK. Vmxnet3 configuration can be obtained using GetVmxnet3Config()

type ContivInitDeps

type ContivInitDeps struct {
	RemoteDB KVBrokerFactory // can be nil
	LocalDB  KVBrokerFactory // can be nil
}

ContivInitDeps lists dependencies of the plugin for use in contiv-init.

type CustomIPAMSubnets

type CustomIPAMSubnets struct {
	// Subnet from which individual POD networks are allocated.
	// This is subnet for all PODs across all nodes.
	PodSubnetCIDR *net.IPNet

	// Prefix length of subnet used for all PODs within 1 node.
	PodSubnetOneNodePrefixLen uint8

	// Subnet used across all nodes for VPP to host Linux stack interconnect.
	VPPHostSubnetCIDR *net.IPNet

	// Prefix length of subnet used for VPP to host stack interconnect
	// within 1 node.
	VPPHostSubnetOneNodePrefixLen uint8

	// Subnet used for inter-node connections.
	NodeInterconnectCIDR *net.IPNet

	// Subnet used for inter-node VXLANs.
	VxlanCIDR *net.IPNet
}

CustomIPAMSubnets allows users to manually select individual subnets. IPAM implementation should respect the selection, but only if ContivCIDR is undefined. Otherwise, the IPAM module is responsible for calculating the subnets by dissecting ContivCIDR by its own algorithm.

type Deps

type Deps struct {
	infra.PluginDeps
	ServiceLabel servicelabel.ReaderAPI

	// GoVPP is not needed for contiv-init but as a plugin it has to be here
	// to be initialized first
	GoVPP GoVPP

	// The ContivConf plugin can be run either from contiv-init or contiv-agent:
	//  - for contiv-init the plugin requires KV broker factory to reload
	//    NodeConfig CRD during Init (inject ContivInitDeps)
	//  - for contiv-agent the plugin requires access to the event loop provided
	//    by the Controller plugin (inject ContivAgentDeps)
	*ContivInitDeps
	*ContivAgentDeps

	// Dependencies to be injected for unit testing to replace any external access
	// with mocks
	*UnitTestDeps
}

Deps lists dependencies of the ContivConf plugin.

type DumpDPDKInterfacesClb

type DumpDPDKInterfacesClb func() (ifaces []string, err error)

DumpDPDKInterfacesClb is callback for dumping DPDK interfaces configured on VPP.

type GetFirstHostInterfaceNameClb

type GetFirstHostInterfaceNameClb func() string

GetFirstHostInterfaceNameClb is callback for retrieving the name of the first non-virtual interface in the host stack.

type GoVPP

type GoVPP interface {
	// NewAPIChannel returns a new API channel for communication with VPP via govpp.
	NewAPIChannel() (govpp.Channel, error)

	// NewAPIChannelBuffered returns a new API channel for communication with VPP via govpp.
	NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (govpp.Channel, error)
}

GoVPP is the interface of govppmux plugin replicated here to avoid direct dependency on vppapiclient.h for other plugins that import contivconf just to read some constants etc.

type IPAMConfig

type IPAMConfig struct {
	// UseExternalIPAM is true if IPAM is provided by an external IPAM plugin instead of Contiv.
	UseExternalIPAM bool

	// UseIPv6 is true if IPv6 networking should be used instead of IPv4.
	UseIPv6 bool

	// CIDR to use for all IP address allocations.
	// If defined (non-nil), the manually selected subnets (CustomIPAMSubnets, see below)
	// should be ignored - i.e. this field takes precedence.
	// IPAM implementation should subdivide the network into smaller chunks to split
	// the address space between nodes and different kinds of endpoints (pods, vxlans, ...)
	// - see CustomIPAMSubnets for the list of subnets to consider.
	// The IPAM algorithm should consider the expected maximum usage of every subnet
	// and allocate the space accordingly to avoid collisions or inefficient
	// address space usage.
	ContivCIDR *net.IPNet // can be nil

	// Subnet used by services.
	ServiceCIDR *net.IPNet

	// if set to true, DHCP is used to acquire IP for the main VPP interface
	// (NodeInterconnectCIDR does not have to be allocated in that case)
	NodeInterconnectDHCP bool

	// DefaultGateway is global option to set default gateway for nodes. Alternatively,
	// nodeConfig can be used
	DefaultGateway net.IP

	// Manually selected subnets (if ContivCIDR is defined, this is overridden
	// by IPAM's own allocation algorithm).
	CustomIPAMSubnets

	// SRv6 settings defining computation of SID/BSID for SRv6 locasids/policies
	SRv6Settings
}

IPAMConfig groups configuration options related to IP address allocation.

type IPVersion

type IPVersion int

IPVersion is either v4 or v6.

const (
	// IPv4 represents IP version 4.
	IPv4 IPVersion = iota
	// IPv6 represents IP version 6.
	IPv6
)

type IPWithNetwork

type IPWithNetwork struct {
	Version IPVersion
	Address net.IP
	Network *net.IPNet
}

IPWithNetwork encapsulates IP address with the network address.

type IPsWithNetworks

type IPsWithNetworks []*IPWithNetwork

IPsWithNetworks is a list of pairs (address, network).

func (IPsWithNetworks) String

func (ips IPsWithNetworks) String() string

String return string representation of IP addresses with networks.

type KVBrokerFactory

type KVBrokerFactory interface {
	NewBroker(keyPrefix string) keyval.ProtoBroker
}

KVBrokerFactory is used to generalize different means of accessing KV-store for the purpose of reading CRD-defined node configuration.

type NodeConfigChange

type NodeConfigChange struct {
	// contains filtered or unexported fields
}

NodeConfigChange is triggered when Node configuration provided via CRD changes. The event is handled by UpstreamResync - the plugins should re-read the configuration provided by ContivConf and re-calculate the state accordingly.

func (*NodeConfigChange) Done

func (ev *NodeConfigChange) Done(error)

Done is NOOP.

func (*NodeConfigChange) GetName

func (ev *NodeConfigChange) GetName() string

GetName returns name of the NodeConfigChange event.

func (*NodeConfigChange) IsBlocking

func (ev *NodeConfigChange) IsBlocking() bool

IsBlocking returns false.

func (*NodeConfigChange) Method

Method is UpstreamResync.

func (*NodeConfigChange) String

func (ev *NodeConfigChange) String() string

String describes NodeIPv4Change event.

type Option

type Option func(conf *ContivConf)

Option is a function that acts on a Plugin to inject Dependencies or configuration

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

type OtherInterfaceConfig

type OtherInterfaceConfig struct {
	InterfaceName string
	UseDHCP       bool
	IPs           IPsWithNetworks
}

OtherInterfaceConfig represents configuration for a non-main VPP interface.

type OtherInterfaces

type OtherInterfaces []*OtherInterfaceConfig

OtherInterfaces is a list of other interfaces.

func (OtherInterfaces) String

func (ifaces OtherInterfaces) String() string

String return string representation of configurations for other interfaces.

type RequestSTNInfoClb

type RequestSTNInfoClb func(ifName string) (reply *stn_grpc.STNReply, err error)

RequestSTNInfoClb is callback for sending request to the STN daemon to obtain information about a stolen interface.

type SRv6Settings

type SRv6Settings struct {
	// ServicePolicyBSIDSubnetCIDR is subnet applied to lowest k8s service IP to get unique
	// (per service,per node) binding sid for SRv6 policy
	ServicePolicyBSIDSubnetCIDR *net.IPNet
	// ServicePodLocalSIDSubnetCIDR is subnet applied to k8s service local pod backend IP to get unique sid
	// for SRv6 Localsid referring to local pod beckend using DX6 end function
	ServicePodLocalSIDSubnetCIDR *net.IPNet
	// ServiceHostLocalSIDSubnetCIDR is subnet applied to k8s service host pod backend IP to get unique sid
	// for SRv6 Localsid referring to local host beckend using DX6 end function
	ServiceHostLocalSIDSubnetCIDR *net.IPNet
	// ServiceNodeLocalSIDSubnetCIDR is subnet applied to node IP to get unique sid for SRv6 Localsid that is
	// intermediate segment routing to other nodes in Srv6 segment list (used in k8s services)
	ServiceNodeLocalSIDSubnetCIDR *net.IPNet
	// NodeToNodePodLocalSIDSubnetCIDR is subnet applied to node IP to get unique sid for SRv6 Localsid that is
	// the only segment in node-to-node Srv6 tunnel. Traffic from tunnel continues routing by looking into
	// pod VRF table (DT6 end function of localsid)
	NodeToNodePodLocalSIDSubnetCIDR *net.IPNet
	// NodeToNodeHostLocalSIDSubnetCIDR is subnet applied to node IP to get unique sid for SRv6 Localsid that
	// is the only segment in node-to-node Srv6 tunnel. Traffic from tunnel continues routing by looking into
	// main VRF table (DT6 end function of localsid)
	NodeToNodeHostLocalSIDSubnetCIDR *net.IPNet
	// NodeToNodePodPolicySIDSubnetCIDR is subnet applied to node IP to get unique bsid for SRv6 policy that
	// defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodePodLocalSIDSubnetCIDR`
	NodeToNodePodPolicySIDSubnetCIDR *net.IPNet
	// NodeToNodeHostPolicySIDSubnetCIDR is subnet applied to node IP to get unique bsid for SRv6 policy that
	// defines path in node-to-node Srv6 tunnel as mentioned in `srv6NodeToNodeHostLocalSIDSubnetCIDR`.
	NodeToNodeHostPolicySIDSubnetCIDR *net.IPNet
	// SFCPolicyBSIDSubnetCIDR is subnet applied to SFC ID(trimmed hash of SFC name) to get unique binding
	// sid for SRv6 policy used in SFC
	SFCPolicyBSIDSubnetCIDR *net.IPNet
	// SFCServiceFunctionSIDSubnetCIDR is subnet applied to combination of SFC ID(trimmed hash of SFC name) and
	// service function pod IP address to get unique sid for SRv6 Localsid referring to SFC service function
	SFCServiceFunctionSIDSubnetCIDR *net.IPNet
	// SFCEndLocalSIDSubnetCIDR is subnet applied to the IP address of last link of SFC to get unique sid
	// for last localsid in the segment routing path representing SFC chain
	SFCEndLocalSIDSubnetCIDR *net.IPNet
	// SFCIDLengthUsedInSidForServiceFunction is length(in bits) of SFC ID(trimmed hash of SFC name) that
	// should be used by computing SFC ServiceFunction localsid SID. A hash is computed from SFC name,
	// trimmed by length (this setting) and used in computation of SFC ServiceFunction localsid SID
	// (SID=prefix from sfcServiceFunctionSIDSubnetCIDR + trimmed hash of SFC name + service function pod
	// IP address).
	SFCIDLengthUsedInSidForServiceFunction uint8
}

SRv6Settings hold all SID/BSID managment settings (SID/BSID is basically IPv6 address)

type STNConfig

type STNConfig struct {
	StealInterface string // can be empty if the interface is already stolen
	STNRoutes      []*stn_grpc.STNReply_Route
	STNSocketFile  string
	STNVersion     uint8
}

STNConfig groups config options related to STN (Steal-the-NIC).

type UnitTestDeps

type UnitTestDeps struct {
	Config                       *config.Config
	DumpDPDKInterfacesClb        DumpDPDKInterfacesClb
	RequestSTNInfoClb            RequestSTNInfoClb
	GetFirstHostInterfaceNameClb GetFirstHostInterfaceNameClb
}

UnitTestDeps lists dependencies for unit testing.

type Vmxnet3Config

type Vmxnet3Config struct {
	MainInterfaceName       string // main interface name as seen by VPP
	MainInterfacePCIAddress string // PCI address of the main interface
}

Vmxnet3Config groups config options related to Vmxnet3 feature.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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