nodesync

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: 17 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of NodeSync.

Functions

This section is empty.

Types

type API

type API interface {
	// GetNodeID returns the integer ID allocated for this node.
	// The method is thread-safe, but should not be called before the startup resync.
	GetNodeID() uint32

	// PublishNodeIPs can be used to publish update about currently assigned
	// node IPs of the given IP version on the VPP-side.
	// The method is efficient enough that it can be called during every resync
	// - only if something has really changed an update will be sent.
	// The method should be called only from within the main event loop (not thread
	// safe) and not before the startup resync.
	PublishNodeIPs(addresses contivconf.IPsWithNetworks, version contivconf.IPVersion) error

	// GetAllNodes returns information about all nodes in the cluster.
	// The method should be called only from within the main event loop (not thread
	// safe) and not before the startup resync.
	GetAllNodes() Nodes // node name -> node info
}

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

type Deps

type Deps struct {
	infra.PluginDeps

	ServiceLabel servicelabel.ReaderAPI
	EventLoop    controller.EventLoop
	DB           KVDBWithAtomic
}

Deps lists dependencies of NodeSync.

type KVDBWithAtomic

type KVDBWithAtomic interface {
	keyval.KvProtoPlugin

	// NewBrokerWithAtomic creates new instance of prefixed (byte-oriented) broker with atomic operations.
	NewBrokerWithAtomic(keyPrefix string) keyval.BytesBrokerWithAtomic

	// Close closes connection to DB and releases all allocated resources.
	Close() error
}

KVDBWithAtomic defines API that a DB client must provide for NodeSync to be able to allocate node IP and to publish node IPs to other nodes.

type Node

type Node struct {
	ID              uint32
	Name            string
	VppIPAddresses  contivconf.IPsWithNetworks
	MgmtIPAddresses []net.IP
	PodCIDR         *net.IPNet
}

Node represents a single node in the cluster.

func (*Node) String

func (n *Node) String() string

String returns a string representation of the node.

type NodeSync

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

NodeSync plugin implements synchronization between Kubernetes nodes running VPP vswitch using a key-value database (by default etcd). Specifically, it allocates the first free positive integer, starting with 1, as a cluster-wide node identifier, primarily used for IP allocations for endpoints inside this node that will not collide with other nodes. Furthermore, NodeSync publishes allocations/changes of the VPP-side of node IP address(es) - information that is not known to Kubernetes.

func NewPlugin

func NewPlugin(opts ...Option) *NodeSync

NewPlugin creates a new Plugin with the provided Options.

func (*NodeSync) Close

func (ns *NodeSync) Close() error

Close is NOOP

func (*NodeSync) GetAllNodes

func (ns *NodeSync) GetAllNodes() Nodes

GetAllNodes returns information about all nodes in the cluster. Methods should not be called before the startup resync. The method should be called only from within the main event loop (not thread safe) and not before the startup resync.

func (*NodeSync) GetNodeID

func (ns *NodeSync) GetNodeID() uint32

GetNodeID returns the integer ID allocated for this node. The method is thread-safe, but should not be called before the startup resync.

func (*NodeSync) HandlesEvent

func (ns *NodeSync) HandlesEvent(event controller.Event) bool

HandlesEvent selects database events - specifically DB entries related to node information.

func (*NodeSync) Init

func (ns *NodeSync) Init() error

Init checks the dependencies.

func (*NodeSync) PublishNodeIPs

func (ns *NodeSync) PublishNodeIPs(addresses contivconf.IPsWithNetworks, version contivconf.IPVersion) error

PublishNodeIPs can be used to publish update about currently assigned node IPs of the given IP version on the VPP-side. The method is efficient enough that it can be called during every resync - only if something has really changed an update will be sent. The method should be called only from within the main event loop (not thread safe) and not before the startup resync.

func (*NodeSync) Resync

func (ns *NodeSync) Resync(event controller.Event, kubeStateData controller.KubeStateData,
	resyncCount int, _ controller.ResyncOperations) error

Resync during startup phase allocates or retrieves already allocated ID for this node. In the runtime, only status of other nodes is re-synchronized.

func (*NodeSync) Revert

func (ns *NodeSync) Revert(event controller.Event) error

Revert is NOOP - plugin handles only BestEffort events.

func (*NodeSync) Update

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

Update is called for KubeStateChange.

type NodeUpdate

type NodeUpdate struct {
	NodeName  string
	PrevState *Node // nil if the node joined the cluster
	NewState  *Node // nil if the node left the cluster
}

NodeUpdate is an Update event that represents change in the status of a K8s node. For other nodes, the event is triggered when:

- node joins the cluster
- node leaves the cluster
- VPP or management IP addresses of the node are updated

For this node, the event is triggered only when:

- the management IP addresses are updated

For update of this node VPP IP addresses, there is already resync event NodeIPv*Change.

func (*NodeUpdate) Direction

func (ev *NodeUpdate) Direction() controller.UpdateDirectionType

Direction is Forward.

func (*NodeUpdate) Done

func (ev *NodeUpdate) Done(error)

Done is NOOP.

func (*NodeUpdate) GetName

func (ev *NodeUpdate) GetName() string

GetName returns name of the NodeUpdate event.

func (*NodeUpdate) IsBlocking

func (ev *NodeUpdate) IsBlocking() bool

IsBlocking returns false.

func (*NodeUpdate) Method

func (ev *NodeUpdate) Method() controller.EventMethodType

Method is Update.

func (*NodeUpdate) String

func (ev *NodeUpdate) String() string

String describes NodeUpdate event.

func (*NodeUpdate) TransactionType

func (ev *NodeUpdate) TransactionType() controller.UpdateTransactionType

TransactionType is BestEffort.

type Nodes

type Nodes map[string]*Node

Nodes is a map of node-name -> Node info.

func (Nodes) String

func (ns Nodes) String() string

String returns a string representation of nodes.

type Option

type Option func(*NodeSync)

Option is a function that can be used in NewPlugin to customize Plugin.

func UseDeps

func UseDeps(f func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL