labelindex

package
v3.8.0-0.dev+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

The labelindex package provides the InheritIndex type, which emits events as the set of items (currently WorkloadEndpoints/HostEndpoint) it has been told about start (or stop) matching the label selectors (which are extracted from the active policy rules) it has been told about.

Label inheritance

As the name suggests, the InheritIndex supports the notion of label inheritance. In our data-model:

  • endpoints have their own labels; these take priority over any inherited labels
  • endpoints also inherit labels from any explicitly-named profiles in their data
  • profiles have explicit labels
  • profiles also have (now deprecated) tags, which we now treat as implicit <tagName>="" labels; explicit profile labels take precidence over implicit tag labels.

For example, suppose an endpoint had labels

{"a": "ep-a", "b": "ep-b"}

and it explicitly referenced profile "profile-A", which had these labels and tags:

{"a": "prof-a", "c": "prof-c", "d": "prof-d"}
["a", "tag-x", "d"]

then the resulting labels for the endpoint after considering inheritance would be:

{
    "a": "ep-a",    // Explicit endpoint label "wins" over profile labels/tags.
    "b": "ep-b",
    "c": "prof-c",  // Profile label gets inherited.
    "d": "prof-d",  // Profile label "wins" over profile tag with same name.
    "tag-x": "",    // Profile tag inherited as empty label.
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPSetMember

type IPSetMember struct {
	CIDR       ip.CIDR
	Protocol   IPSetPortProtocol
	PortNumber uint16
}

type IPSetPortProtocol

type IPSetPortProtocol uint8
const (
	ProtocolNone IPSetPortProtocol = 0
	ProtocolTCP  IPSetPortProtocol = 6
	ProtocolUDP  IPSetPortProtocol = 17
)

func (IPSetPortProtocol) MatchesModelProtocol

func (p IPSetPortProtocol) MatchesModelProtocol(protocol numorstring.Protocol) bool

func (IPSetPortProtocol) String

func (p IPSetPortProtocol) String() string

type InheritIndex

type InheritIndex struct {

	// Callback functions
	OnMatchStarted MatchCallback
	OnMatchStopped MatchCallback
	// contains filtered or unexported fields
}

func NewInheritIndex

func NewInheritIndex(onMatchStarted, onMatchStopped MatchCallback) *InheritIndex

func (*InheritIndex) DeleteLabels

func (idx *InheritIndex) DeleteLabels(id interface{})

func (*InheritIndex) DeleteParentLabels

func (idx *InheritIndex) DeleteParentLabels(parentID string)

func (*InheritIndex) DeleteParentTags

func (idx *InheritIndex) DeleteParentTags(parentID string)

func (*InheritIndex) DeleteSelector

func (idx *InheritIndex) DeleteSelector(id interface{})

func (*InheritIndex) OnUpdate

func (l *InheritIndex) OnUpdate(update api.Update) (_ bool)

OnUpdate makes LabelInheritanceIndex compatible with the UpdateHandler interface allowing it to be used in a calculation graph more easily.

func (*InheritIndex) UpdateLabels

func (idx *InheritIndex) UpdateLabels(id interface{}, labels map[string]string, parentIDs []string)

func (*InheritIndex) UpdateParentLabels

func (idx *InheritIndex) UpdateParentLabels(parentID string, labels map[string]string)

func (*InheritIndex) UpdateParentTags

func (idx *InheritIndex) UpdateParentTags(parentID string, tags []string)

func (*InheritIndex) UpdateSelector

func (idx *InheritIndex) UpdateSelector(id interface{}, sel selector.Selector)

type MatchCallback

type MatchCallback func(selId, labelId interface{})

type NamedPortMatchCallback

type NamedPortMatchCallback func(ipSetID string, member IPSetMember)

type SelectorAndNamedPortIndex

type SelectorAndNamedPortIndex struct {

	// Callback functions
	OnMemberAdded   NamedPortMatchCallback
	OnMemberRemoved NamedPortMatchCallback
	// contains filtered or unexported fields
}

func NewSelectorAndNamedPortIndex

func NewSelectorAndNamedPortIndex() *SelectorAndNamedPortIndex

func (*SelectorAndNamedPortIndex) CalculateEndpointContribution

func (idx *SelectorAndNamedPortIndex) CalculateEndpointContribution(d *endpointData, ipSetData *ipSetData) (contrib []IPSetMember)

CalculateEndpointContribution calculates the given endpoint's contribution to the given IP set. If the IP set represents a named port then the returned members will have a named port component. Returns nil if the endpoint doesn't contribute to the IP set.

func (*SelectorAndNamedPortIndex) DeleteEndpoint

func (idx *SelectorAndNamedPortIndex) DeleteEndpoint(id interface{})

func (*SelectorAndNamedPortIndex) DeleteIPSet

func (idx *SelectorAndNamedPortIndex) DeleteIPSet(id string)

func (*SelectorAndNamedPortIndex) DeleteParentLabels

func (idx *SelectorAndNamedPortIndex) DeleteParentLabels(parentID string)

func (*SelectorAndNamedPortIndex) DeleteParentTags

func (idx *SelectorAndNamedPortIndex) DeleteParentTags(parentID string)

func (*SelectorAndNamedPortIndex) OnUpdate

func (idx *SelectorAndNamedPortIndex) OnUpdate(update api.Update) (_ bool)

OnUpdate makes SelectorAndNamedPortIndex compatible with the Dispatcher. It accepts updates for endpoints and profiles and passes them through to the Update/DeleteXXX methods.

func (*SelectorAndNamedPortIndex) RecalcCachedContributions

func (idx *SelectorAndNamedPortIndex) RecalcCachedContributions(epData *endpointData) map[string][]IPSetMember

RecalcCachedContributions uses the cached set of matching IP set IDs in the endpoint struct to quickly recalculate the endpoint's contribution to all IP sets.

func (*SelectorAndNamedPortIndex) RegisterWith

func (idx *SelectorAndNamedPortIndex) RegisterWith(allUpdDispatcher *dispatcher.Dispatcher)

func (*SelectorAndNamedPortIndex) UpdateEndpointOrSet

func (idx *SelectorAndNamedPortIndex) UpdateEndpointOrSet(
	id interface{},
	labels map[string]string,
	nets []ip.CIDR,
	ports []model.EndpointPort,
	parentIDs []string,
)

func (*SelectorAndNamedPortIndex) UpdateIPSet

func (idx *SelectorAndNamedPortIndex) UpdateIPSet(ipSetID string, sel selector.Selector, namedPortProtocol IPSetPortProtocol, namedPort string)

func (*SelectorAndNamedPortIndex) UpdateParentLabels

func (idx *SelectorAndNamedPortIndex) UpdateParentLabels(parentID string, labels map[string]string)

func (*SelectorAndNamedPortIndex) UpdateParentTags

func (idx *SelectorAndNamedPortIndex) UpdateParentTags(parentID string, tags []string)

Jump to

Keyboard shortcuts

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