processor

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Log          logging.Logger
	ServiceLabel servicelabel.ReaderAPI
	Contiv       contiv.API /* to get all interface names and pod IP network */
}

Deps lists dependencies of ServiceProcessor.

type LocalEndpoint

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

LocalEndpoint represents a node-local endpoint.

type ResyncEventData

type ResyncEventData struct {
	Nodes     map[int]*nodemodel.NodeInfo
	Pods      []*podmodel.Pod
	Endpoints []*epmodel.Endpoints
	Services  []*svcmodel.Service
}

ResyncEventData wraps an entire state of K8s services that should be reflected into VPP.

func NewResyncEventData

func NewResyncEventData() *ResyncEventData

NewResyncEventData creates an empty instance of ResyncEventData.

func (ResyncEventData) String

func (red ResyncEventData) String() string

String converts ResyncEventData into a human-readable string.

type Service

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

Service is used to combine data from the service model with the endpoints.

func NewService

func NewService(sp *ServiceProcessor) *Service

NewService is a constructor for Service.

func (*Service) GetContivService

func (s *Service) GetContivService() *renderer.ContivService

GetContivService returns the service data represented as ContivService. Returns nil if there are not enough available data.

func (*Service) GetLocalBackends

func (s *Service) GetLocalBackends() []podmodel.ID

GetLocalBackends returns the set of IDs od all local backends of this service. Returns empty array if there are not enough available data.

func (*Service) Refresh

func (s *Service) Refresh()

Refresh combines metadata with endpoints to get ContivService representation and the list of local backends.

func (*Service) SetEndpoints

func (s *Service) SetEndpoints(endpoints *epmodel.Endpoints)

SetEndpoints initializes or changes endpoints for the service.

func (*Service) SetMetadata

func (s *Service) SetMetadata(meta *svcmodel.Service)

SetMetadata initializes or changes metadata for the service.

type ServiceProcessor

type ServiceProcessor struct {
	Deps

	sync.Mutex
	// contains filtered or unexported fields
}

ServiceProcessor implements ServiceProcessorAPI.

func (*ServiceProcessor) AfterInit

func (sp *ServiceProcessor) AfterInit() error

AfterInit does nothing for the processor.

func (*ServiceProcessor) Close

func (sp *ServiceProcessor) Close() error

Close deallocates resource held by the processor.

func (*ServiceProcessor) Init

func (sp *ServiceProcessor) Init() error

Init initializes service processor.

func (*ServiceProcessor) RegisterRenderer

func (sp *ServiceProcessor) RegisterRenderer(renderer renderer.ServiceRendererAPI) error

RegisterRenderer registers a new service renderer. The renderer will be receiving updates for all services on the cluster.

func (*ServiceProcessor) Resync

func (sp *ServiceProcessor) Resync(resyncEv datasync.ResyncEvent) error

Resync processes a datasync resync event associated with the state data of K8s pods, endpoints, services and nodes. The cache content is fully replaced and all registered renderers receive a full snapshot of Contiv Services at the present state to be (re)installed.

func (*ServiceProcessor) Update

func (sp *ServiceProcessor) Update(dataChngEv datasync.ChangeEvent) error

Update processes a datasync change event associated with the state data of K8s pods, endpoints, services and nodes. The data change is stored into the cache and all registered renderers are notified about any changes related to services that need to be reflected in the underlying network stack(s).

type ServiceProcessorAPI

type ServiceProcessorAPI interface {
	// Update processes a datasync change event associated with the state data
	// of K8s pods, endpoints, services and nodes.
	// The data change is stored into the cache and all registered renderers
	// are notified about any changes related to services that need to be
	// reflected in the underlying network stack(s).
	Update(dataChngEv datasync.ChangeEvent) error

	// Resync processes a datasync resync event associated with the state data
	// of K8s pods, endpoints, services and nodes.
	// The cache content is fully replaced and all registered renderers
	// receive a full snapshot of Contiv Services at the present state to be
	// (re)installed.
	Resync(resyncEv datasync.ResyncEvent) error

	// RegisterRenderer registers a new service renderer.
	// The renderer will be receiving updates for all services on the cluster.
	RegisterRenderer(renderer renderer.ServiceRendererAPI) error
}

ServiceProcessorAPI defines the API of the Service Processor.

The processor receives RESYNC and data-change events for endpoints and services from the service plugin. The state of the K8s configuration is internally cached (since the last RESYNC). The cache is used to match subsets of endpoints with the corresponding service definition (including ports). Based on the service type, the list of addresses on which the service should be exposed is determined.

Processor also maintains the set of interfaces connecting frontends (physical interfaces and pods that do not run any service) and backends (pods which act as endpoints of at least one service). The set of physical interfaces and interfaces connecting pods are learned from the Contiv plugin.

The combined service and endpoint state/configuration data are passed further to all registered renderers. The processor allows to register multiple renderers at once, each receiving the same set of data.

Jump to

Keyboard shortcuts

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