configurator

package
v0.0.0-...-a11b7ec Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LocalVsRemoteProbRatio uint32 = 2

LocalVsRemoteProbRatio tells how much more likely a local backend is to receive traffic as opposed to a remote backend.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContivService

type ContivService struct {
	// ID should uniquely identify service across all namespaces.
	ID svcmodel.ID

	// TrafficPolicy decides if traffic is routed cluster-wide or node-local only.
	TrafficPolicy TrafficPolicyType

	// ExternalIPs is a set of all IP addresses on which the service
	// should be exposed on this node.
	ExternalIPs *IPAddresses

	// Ports is a map of all ports exposed for this service.
	Ports map[string]*ServicePort

	// Backends map external service ports with corresponding backends.
	Backends map[string][]*ServiceBackend
}

ContivService is a less-abstract, free of indirect references representation of K8s Service. It has:

  • endpoints combined with services
  • the full list of IP addresses on which the service should be exposed on this node

It is produced in this form and passed to Configurator by Service Processor.

func NewContivService

func NewContivService() *ContivService

NewContivService is a constructor for ContivService.

func (ContivService) HasNodePort

func (cs ContivService) HasNodePort() bool

HasNodePort returns true if service is also exposed on the Node IP.

func (ContivService) String

func (cs ContivService) String() string

String converts ContivService into a human-readable string.

type Deps

type Deps struct {
	Log           logging.Logger
	VPP           defaultplugins.API /* for DumpNat44Global & DumpNat44DNat */
	NATTxnFactory func() (dsl linux.DataChangeDSL)
}

Deps lists dependencies of ServiceConfigurator.

type ExternalSNATConfig

type ExternalSNATConfig struct {
	// ExternalIfName is the name of the interface used as the gateway to the external network.
	// If empty, the SNAT is not configured.
	ExternalIfName string

	// ExternalIP is the IP address that will be used as the source address in (S)NAT for all traffic leaving
	// the cluster network.
	// If nil, the SNAT is not configured.
	ExternalIP net.IP
}

ExternalSNATConfig encapsulates configuration concerning SNAT, installed to allow Internet access for pods.

func (ExternalSNATConfig) String

func (esc ExternalSNATConfig) String() string

String converts ExternalSNATConfig into a human-readable string.

type IPAddresses

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

IPAddresses is a set of IP addresses.

func NewIPAddresses

func NewIPAddresses(addrs ...net.IP) *IPAddresses

NewIPAddresses is a constructor for IPAddresses.

func (*IPAddresses) Add

func (addrs *IPAddresses) Add(addr net.IP)

Add IP address into the set.

func (*IPAddresses) Copy

func (addrs *IPAddresses) Copy() *IPAddresses

Copy creates a deep copy of the set.

func (*IPAddresses) Del

func (addrs *IPAddresses) Del(addr net.IP)

Del IP address from the set.

func (*IPAddresses) Has

func (addrs *IPAddresses) Has(addr net.IP) bool

Has returns true if the given IP address is in the set.

func (*IPAddresses) List

func (addrs *IPAddresses) List() []net.IP

List returns the set as a slice which can be iterated through.

func (IPAddresses) String

func (addrs IPAddresses) String() string

String converts a set of IP addresses into a human-readable string.

type Interfaces

type Interfaces map[string]struct{}

Interfaces is a set of interface names.

func NewInterfaces

func NewInterfaces(ifNames ...string) Interfaces

NewInterfaces is a constructor for Interfaces.

func (Interfaces) Add

func (ifs Interfaces) Add(ifName string)

Add interface name into the set.

func (Interfaces) Copy

func (ifs Interfaces) Copy() Interfaces

Copy creates a deep copy of the set.

func (Interfaces) Del

func (ifs Interfaces) Del(ifName string)

Del interface name from the set.

func (Interfaces) Has

func (ifs Interfaces) Has(ifName string) bool

Has returns true if the given interface name is in the set.

func (Interfaces) String

func (ifs Interfaces) String() string

String converts a set of interface names into a human-readable string.

type ProtocolType

type ProtocolType int

ProtocolType is either TCP or UDP.

const (
	// TCP protocol.
	TCP ProtocolType = 6

	// UDP protocol.
	UDP ProtocolType = 17
)

func (ProtocolType) String

func (pt ProtocolType) String() string

String converts ProtocolType into a human-readable string.

type ResyncEventData

type ResyncEventData struct {
	// NodeIPs is a list of IP addresses of all nodes in the cluster.
	NodeIPs []net.IP

	// ExternalSNAT contains configuration of SNAT, installed to allow access outside the cluster network.
	ExternalSNAT ExternalSNATConfig

	// Services is a list of all currently deployed services.
	Services []*ContivService

	// FrontendIfs is a set of all interfaces connecting clients with VPP.
	FrontendIfs Interfaces

	// BackendIfs is a set of all interfaces connecting service backends with VPP.
	BackendIfs Interfaces
}

ResyncEventData wraps an entire state of K8s services.

func NewResyncEventData

func NewResyncEventData() *ResyncEventData

NewResyncEventData is a constructor for ResyncEventData.

func (ResyncEventData) String

func (red ResyncEventData) String() string

String converts ResyncEventData into a human-readable string.

type ServiceBackend

type ServiceBackend struct {
	IP    net.IP /* internal IP address of the backend */
	Port  uint16 /* backend-local port on which the service listens */
	Local bool   /* true if the backend is deployed on this node  */
}

ServiceBackend represents a single service backend.

func (ServiceBackend) String

func (sb ServiceBackend) String() string

String converts Backend into a human-readable string.

type ServiceConfigurator

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

ServiceConfigurator implements ServiceConfiguratorAPI.

func (*ServiceConfigurator) AddService

func (sc *ServiceConfigurator) AddService(service *ContivService) error

AddService installs NAT rules for a newly added service.

func (*ServiceConfigurator) Close

func (sc *ServiceConfigurator) Close() error

Close deallocates resources held by the configurator.

func (*ServiceConfigurator) DeleteService

func (sc *ServiceConfigurator) DeleteService(service *ContivService) error

DeleteService removes NAT configuration associated with a newly undeployed service.

func (*ServiceConfigurator) Init

func (sc *ServiceConfigurator) Init() error

Init initializes service configurator.

func (*ServiceConfigurator) Resync

func (sc *ServiceConfigurator) Resync(resyncEv *ResyncEventData) error

Resync completely replaces the current NAT configuration with the provided full state of K8s services.

func (*ServiceConfigurator) UpdateLocalBackendIfs

func (sc *ServiceConfigurator) UpdateLocalBackendIfs(oldIfNames, newIfNames Interfaces) error

UpdateLocalBackendIfs updates the list of interfaces connecting service backends with VPP (enabled in2out VPP/NAT feature).

func (*ServiceConfigurator) UpdateLocalFrontendIfs

func (sc *ServiceConfigurator) UpdateLocalFrontendIfs(oldIfNames, newIfNames Interfaces) error

UpdateLocalFrontendIfs updates the list of interfaces connecting clients with VPP (enabled out2in VPP/NAT feature).

func (*ServiceConfigurator) UpdateNodePortServices

func (sc *ServiceConfigurator) UpdateNodePortServices(nodeIPs []net.IP, npServices []*ContivService) error

UpdateNodePortServices updates configuration of nodeport services to reflect changed list of all node IPs in the cluster.

func (*ServiceConfigurator) UpdateService

func (sc *ServiceConfigurator) UpdateService(oldService, newService *ContivService) error

UpdateService reflects a change in the configuration of a service with the smallest number of VPP/NAT binary API calls necessary.

type ServiceConfiguratorAPI

type ServiceConfiguratorAPI interface {
	// AddService installs NAT rules for a newly added service.
	AddService(service *ContivService) error

	// UpdateService reflects a change in the configuration of a service with
	// the smallest number of VPP/NAT binary API calls necessary.
	UpdateService(oldService, newService *ContivService) error

	// DeleteService removes NAT configuration associated with a newly undeployed
	// service.
	DeleteService(service *ContivService) error

	// UpdateNodePortServices updates configuration of nodeport services to reflect
	// changed list of all node IPs in the cluster.
	UpdateNodePortServices(nodeIPs []net.IP, npServices []*ContivService) error

	// UpdateLocalFrontendIfs updates the list of interfaces connecting clients
	// with VPP (enabled out2in VPP/NAT feature).
	UpdateLocalFrontendIfs(oldIfNames, newIfNames Interfaces) error

	// UpdateLocalBackendIfs updates the list of interfaces connecting service
	// backends with VPP (enabled in2out VPP/NAT feature).
	UpdateLocalBackendIfs(oldIfNames, newIfNames Interfaces) error

	// Resync completely replaces the current NAT configuration with the provided
	// full state of K8s services.
	Resync(resyncEv *ResyncEventData) error
}

ServiceConfiguratorAPI defines the API of Service Configurator. Until we have NAT44 supported in the vpp-agent, the configurator installs the configuration directly via VPP/NAT plugin binary API:

  • translates ContivService into the corresponding NAT configuration
  • applies out2in and in2out VPP/NAT's features on interfaces connecting frontends and backends, respectivelly
  • for each change, calculates the minimal diff, i.e. the smallest set of binary API request that need to be executed to get the NAT configuration in-sync with the state of K8s services

type ServicePort

type ServicePort struct {
	Protocol ProtocolType /* protocol type */
	Port     uint16       /* port that will be exposed by this service */
	NodePort uint16       /* port on which this service is exposed for Node IP (0 if none) */
}

ServicePort contains information on service's port.

func (ServicePort) String

func (sp ServicePort) String() string

String converts ServicePort into a human-readable string.

type TrafficPolicyType

type TrafficPolicyType int

TrafficPolicyType is either Cluster-wide routing or Node-local only routing.

const (
	// ClusterWide allows to load-balance traffic across all backends.
	ClusterWide TrafficPolicyType = 0

	// NodeLocal allows to load-balance traffic only across node-local backends.
	NodeLocal TrafficPolicyType = 1
)

func (TrafficPolicyType) String

func (tpt TrafficPolicyType) String() string

String converts TrafficPolicyType into a human-readable string.

Jump to

Keyboard shortcuts

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