Documentation ¶
Index ¶
- Variables
- type API
- type Config
- type ContivAgentDeps
- type ContivConf
- func (c *ContivConf) Close() error
- func (c *ContivConf) EnablePacketTrace() bool
- func (c *ContivConf) GetIPAMConfig() *IPAMConfig
- func (c *ContivConf) GetIPAMConfigForJSON() *IPAMConfigForJSON
- func (c *ContivConf) GetIPNeighborScanConfig() *IPNeighborScanConfig
- func (c *ContivConf) GetInterfaceConfig() *InterfaceConfig
- func (c *ContivConf) GetMainInterfaceConfiguredIPs() IPsWithNetworks
- func (c *ContivConf) GetMainInterfaceName() string
- func (c *ContivConf) GetOtherVPPInterfaces() OtherInterfaces
- func (c *ContivConf) GetRoutingConfig() *RoutingConfig
- func (c *ContivConf) GetSTNConfig() *STNConfig
- func (c *ContivConf) GetStaticDefaultGW() net.IP
- func (c *ContivConf) GetVmxnet3Config() (*Vmxnet3Config, error)
- func (c *ContivConf) HandlesEvent(event controller.Event) bool
- func (c *ContivConf) InSTNMode() bool
- func (c *ContivConf) Init() (err error)
- func (c *ContivConf) NatExternalTraffic() bool
- func (c *ContivConf) Resync(event controller.Event, kubeStateData controller.KubeStateData, ...) (err error)
- func (c *ContivConf) Revert(event controller.Event) error
- func (c *ContivConf) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
- func (c *ContivConf) UseDHCP() bool
- func (c *ContivConf) UseVmxnet3() bool
- type ContivInitDeps
- type CustomIPAMSubnets
- type Deps
- type DumpDPDKInterfacesClb
- type GetFirstHostInterfaceNameClb
- type GoVPP
- type IPAMConfig
- type IPAMConfigForJSON
- type IPNeighborScanConfig
- type IPVersion
- type IPWithNetwork
- type IPsWithNetworks
- type InterfaceConfig
- type KVBrokerFactory
- type NodeConfig
- type NodeConfigChange
- type Option
- type OtherInterfaceConfig
- type OtherInterfaces
- type RequestSTNInfoClb
- type RoutingConfig
- type STNConfig
- type UnitTestDeps
- type Vmxnet3Config
Constants ¶
This section is empty.
Variables ¶
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() *IPAMConfigForJSON // GetInterfaceConfig returns configuration related to VPP interfaces. GetInterfaceConfig() *InterfaceConfig // GetRoutingConfig returns configuration related to IP routing. GetRoutingConfig() *RoutingConfig // GetIPNeighborScanConfig returns configuration related to IP Neighbor // scanning. GetIPNeighborScanConfig() *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 Config ¶
type Config struct { InterfaceConfig RoutingConfig IPNeighborScanConfig StealFirstNIC bool `json:"stealFirstNIC,omitempty"` StealInterface string `json:"stealInterface,omitempty"` STNSocketFile string `json:"stnSocketFile,omitempty"` STNVersion uint8 `json:"stnVersion,omitempty"` NatExternalTraffic bool `json:"natExternalTraffic,omitempty"` EnablePacketTrace bool `json:"enablePacketTrace,omitempty"` CRDNodeConfigurationDisabled bool `json:"crdNodeConfigurationDisabled,omitempty"` IPAMConfig IPAMConfigForJSON `json:"ipamConfig"` NodeConfig []NodeConfig `json:"nodeConfig"` }
Config represents configuration for the Contiv agent. The path to the configuration file can be specified in two ways:
- using the `-contiv-config=<path to config>` argument, or
- using the `CONTIV_CONFIG=<path to config>` environment variable
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) 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() *IPAMConfigForJSON
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() *IPNeighborScanConfig
GetIPNeighborScanConfig returns configuration related to IP Neighbor scanning.
func (*ContivConf) GetInterfaceConfig ¶
func (c *ContivConf) GetInterfaceConfig() *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() *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 ¶
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 // 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 }
IPAMConfig groups configuration options related to IP address allocation.
type IPAMConfigForJSON ¶
type IPAMConfigForJSON struct { UseExternalIPAM bool `json:"useExternalIPAM,omitempty"` ContivCIDR string `json:"contivCIDR,omitempty"` ServiceCIDR string `json:"serviceCIDR,omitempty"` NodeInterconnectDHCP bool `json:"nodeInterconnectDHCP,omitempty"` PodSubnetCIDR string `json:"podSubnetCIDR,omitempty"` PodSubnetOneNodePrefixLen uint8 `json:"podSubnetOneNodePrefixLen,omitempty"` VPPHostSubnetCIDR string `json:"vppHostSubnetCIDR,omitempty"` VPPHostSubnetOneNodePrefixLen uint8 `json:"vppHostSubnetOneNodePrefixLen,omitempty"` NodeInterconnectCIDR string `json:"nodeInterconnectCIDR,omitempty"` VxlanCIDR string `json:"vxlanCIDR,omitempty"` DefaultGateway string `json:"defaultGateway,omitempty"` }
IPAMConfigForJSON groups IPAM configuration options as basic data types and with JSON tags, ready to be un-marshalled from the configuration. The string fields are then parsed to *net.IPNet and returned as such in IPAMConfig structure.
type IPNeighborScanConfig ¶
type IPNeighborScanConfig struct { // when enabled, IP neighbors should be periodically scanned and probed // to maintain the ARP table ScanIPNeighbors bool `json:"scanIPNeighbors,omitempty"` IPNeighborScanInterval uint8 `json:"ipNeighborScanInterval,omitempty"` IPNeighborStaleThreshold uint8 `json:"ipNeighborStaleThreshold,omitempty"` }
IPNeighborScanConfig contains configuration related to IP neighbour scanning.
type IPWithNetwork ¶
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 InterfaceConfig ¶
type InterfaceConfig struct { MTUSize uint32 `json:"mtuSize,omitempty"` UseTAPInterfaces bool `json:"useTAPInterfaces,omitempty"` TAPInterfaceVersion uint8 `json:"tapInterfaceVersion,omitempty"` TAPv2RxRingSize uint16 `json:"tapv2RxRingSize,omitempty"` TAPv2TxRingSize uint16 `json:"tapv2TxRingSize,omitempty"` Vmxnet3RxRingSize uint16 `json:"vmxnet3RxRingSize,omitempty"` Vmxnet3TxRingSize uint16 `json:"vmxnet3TxRingSize,omitempty"` InterfaceRxMode string `json:"interfaceRxMode,omitempty"` // "" == "default" / "polling" / "interrupt" / "adaptive" TCPChecksumOffloadDisabled bool `json:"tcpChecksumOffloadDisabled,omitempty"` }
InterfaceConfig contains configuration related to interfaces.
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 NodeConfig ¶
type NodeConfig struct { // name of the node, should match with the hostname NodeName string `json:"nodeName"` // node config specification can be defined either via the configuration file // or using CRD nodeconfigcrd.NodeConfigSpec }
NodeConfig represents configuration specific to a given node.
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) 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 ¶
func (ev *NodeConfigChange) Method() controller.EventMethodType
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
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 ¶
RequestSTNInfoClb is callback for sending request to the STN daemon to obtain information about a stolen interface.
type RoutingConfig ¶
type RoutingConfig struct { // VRF IDs MainVRFID uint32 `json:"mainVRFID,omitempty"` PodVRFID uint32 `json:"podVRFID,omitempty"` // enabled when nodes are on the same L2 network and VXLANs are therefore // not needed UseL2Interconnect bool `json:"useL2Interconnect,omitempty"` // when enabled, cluster IP CIDR should be routed towards VPP from Linux RouteServiceCIDRToVPP bool `json:"routeServiceCIDRToVPP,omitempty"` }
RoutingConfig groups configuration options related to routing.
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 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.