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 ¶
- type InheritIndex
- func (idx *InheritIndex) DeleteLabels(id interface{})
- func (idx *InheritIndex) DeleteParentLabels(parentID string)
- func (idx *InheritIndex) DeleteParentTags(parentID string)
- func (idx *InheritIndex) DeleteSelector(id interface{})
- func (l *InheritIndex) OnUpdate(update api.Update) (_ bool)
- func (l *InheritIndex) RegisterWith(allUpdDispatcher *dispatcher.Dispatcher)
- func (idx *InheritIndex) UpdateLabels(id interface{}, labels map[string]string, parentIDs []string)
- func (idx *InheritIndex) UpdateParentLabels(parentID string, labels map[string]string)
- func (idx *InheritIndex) UpdateParentTags(parentID string, tags []string)
- func (idx *InheritIndex) UpdateSelector(id interface{}, sel selector.Selector)
- type MatchCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) RegisterWith ¶
func (l *InheritIndex) RegisterWith(allUpdDispatcher *dispatcher.Dispatcher)
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{})