Documentation ¶
Index ¶
- type DataResyncEvent
- type Deps
- type PolicyCache
- func (pc *PolicyCache) Init() error
- func (pc *PolicyCache) ListAllNamespaces() (namespaces []nsmodel.ID)
- func (pc *PolicyCache) ListAllPods() (pods []podmodel.ID)
- func (pc *PolicyCache) ListAllPolicies() (policies []policymodel.ID)
- func (pc *PolicyCache) LookupNamespace(namespace nsmodel.ID) (found bool, data *nsmodel.Namespace)
- func (pc *PolicyCache) LookupNamespacesByLabelSelector(nsLabelSelector *policymodel.Policy_LabelSelector) (namespaces []nsmodel.ID)
- func (pc *PolicyCache) LookupPod(pod podmodel.ID) (found bool, data *podmodel.Pod)
- func (pc *PolicyCache) LookupPodsByLabelSelector(podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID)
- func (pc *PolicyCache) LookupPodsByNSLabelSelector(policyNamespace string, podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID)
- func (pc *PolicyCache) LookupPodsByNamespace(namespace nsmodel.ID) (pods []podmodel.ID)
- func (pc *PolicyCache) LookupPoliciesByPod(pod podmodel.ID) (policies []policymodel.ID)
- func (pc *PolicyCache) LookupPolicy(policy policymodel.ID) (found bool, data *policymodel.Policy)
- func (pc *PolicyCache) Resync(resyncEv datasync.ResyncEvent) error
- func (pc *PolicyCache) Update(dataChngEv datasync.ChangeEvent) error
- func (pc *PolicyCache) Watch(watcher PolicyCacheWatcher) error
- type PolicyCacheAPI
- type PolicyCacheWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataResyncEvent ¶
type DataResyncEvent struct { Namespaces []*namespacemodel.Namespace Pods []*podmodel.Pod Policies []*policymodel.Policy }
DataResyncEvent wraps an entire state of K8s that should be reflected into VPP.
func NewDataResyncEvent ¶
func NewDataResyncEvent() *DataResyncEvent
NewDataResyncEvent creates an empty instance of DataResyncEvent.
type Deps ¶
type Deps struct { Log logging.Logger PluginName core.PluginName }
Deps lists dependencies of PolicyCache.
type PolicyCache ¶
type PolicyCache struct { Deps // contains filtered or unexported fields }
PolicyCache s used for a in-memory storage of K8s State data with fast lookups using idxmap-s. The cache processes K8s State data updates and RESYNC events through Update() and Resync() APIs, respectively. The cache allows to get notified about changes via convenient callbacks. A watcher needs to implement the interface PolicyCacheWatcher and subscribe for watching using Watch() API. The cache provides various fast lookup methods (e.g. by the label selector).
func (*PolicyCache) ListAllNamespaces ¶
func (pc *PolicyCache) ListAllNamespaces() (namespaces []nsmodel.ID)
ListAllNamespaces returns IDs of all known namespaces.
func (*PolicyCache) ListAllPods ¶
func (pc *PolicyCache) ListAllPods() (pods []podmodel.ID)
ListAllPods returns IDs of all known pods.
func (*PolicyCache) ListAllPolicies ¶
func (pc *PolicyCache) ListAllPolicies() (policies []policymodel.ID)
ListAllPolicies returns IDs of all policies.
func (*PolicyCache) LookupNamespace ¶
LookupNamespace returns data of a given namespace.
func (*PolicyCache) LookupNamespacesByLabelSelector ¶
func (pc *PolicyCache) LookupNamespacesByLabelSelector( nsLabelSelector *policymodel.Policy_LabelSelector) (namespaces []nsmodel.ID)
LookupNamespacesByLabelSelector evaluates label selector (expression and/or match labels) and returns IDs of matching namespaces.
func (*PolicyCache) LookupPodsByLabelSelector ¶
func (pc *PolicyCache) LookupPodsByLabelSelector( podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID)
LookupPodsByLabelSelector evaluates label selector (expression and/or match labels) and returns IDs of matching pods.
func (*PolicyCache) LookupPodsByNSLabelSelector ¶
func (pc *PolicyCache) LookupPodsByNSLabelSelector(policyNamespace string, podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID)
LookupPodsByNSLabelSelector evaluates label selector (expression and/or match labels) and returns IDs of matching pods in a namespace.
func (*PolicyCache) LookupPodsByNamespace ¶
func (pc *PolicyCache) LookupPodsByNamespace(namespace nsmodel.ID) (pods []podmodel.ID)
LookupPodsByNamespace returns IDs of all pods inside a given namespace.
func (*PolicyCache) LookupPoliciesByPod ¶
func (pc *PolicyCache) LookupPoliciesByPod(pod podmodel.ID) (policies []policymodel.ID)
LookupPoliciesByPod returns IDs of all policies assigned to a given pod.
func (*PolicyCache) LookupPolicy ¶
func (pc *PolicyCache) LookupPolicy(policy policymodel.ID) (found bool, data *policymodel.Policy)
LookupPolicy returns data of a given Policy.
func (*PolicyCache) Resync ¶
func (pc *PolicyCache) Resync(resyncEv datasync.ResyncEvent) error
Resync processes a datasync resync event associated with K8s State data. The cache content is full replaced with the received data and all subscribed watchers are notified. The function will forward any error returned by a watcher.
func (*PolicyCache) Update ¶
func (pc *PolicyCache) Update(dataChngEv datasync.ChangeEvent) error
Update processes a datasync change event associated with K8s State data. The change is applied into the cache and all subscribed watchers are notified. The function will forward any error returned by a watcher.
func (*PolicyCache) Watch ¶
func (pc *PolicyCache) Watch(watcher PolicyCacheWatcher) error
Watch subscribes a new watcher.
type PolicyCacheAPI ¶
type PolicyCacheAPI interface { // Update processes a datasync change event associated with K8s State data. // The change is applied into the cache and all subscribed watchers are // notified. // The function will forward any error returned by a watcher. Update(dataChngEv datasync.ChangeEvent) error // Resync processes a datasync resync event associated with K8s State data. // The cache content is full replaced with the received data and all // subscribed watchers are notified. // The function will forward any error returned by a watcher. Resync(resyncEv datasync.ResyncEvent) error // Watch subscribes a new watcher. Watch(watcher PolicyCacheWatcher) error // LookupPod returns data of a given Pod. LookupPod(pod podmodel.ID) (found bool, data *podmodel.Pod) // LookupPodsByLabelSelector evaluates label selector (expression and/or match // labels) and returns IDs of matching pods. LookupPodsByLabelSelector(podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID) // LookupPodsByNSLabelSelector evaluates label selector (expression and/or match // labels and returns IDs of matching pods in a namespace. LookupPodsByNSLabelSelector(namespace string, podLabelSelector *policymodel.Policy_LabelSelector) (pods []podmodel.ID) // LookupPodsByNamespace returns IDs of all pods inside a given namespace. LookupPodsByNamespace(namespace nsmodel.ID) (pods []podmodel.ID) // ListAllPods returns IDs of all known pods. ListAllPods() (pods []podmodel.ID) // LookupPolicy returns data of a given Policy. LookupPolicy(policy policymodel.ID) (found bool, data *policymodel.Policy) // LookupPoliciesByPod returns IDs of all policies assigned to a given pod. LookupPoliciesByPod(pod podmodel.ID) (policies []policymodel.ID) // ListAllPolicies returns IDs of all policies. ListAllPolicies() (policies []policymodel.ID) // LookupNamespace returns data of a given namespace. LookupNamespace(namespace nsmodel.ID) (found bool, data *nsmodel.Namespace) // LookupNamespacesByLabelSelector evaluates label selector (expression // and/or match labels) and returns IDs of matching namespaces. LookupNamespacesByLabelSelector(nsLabelSelector *policymodel.Policy_LabelSelector) (namespaces []nsmodel.ID) // ListAllNamespaces returns IDs of all known namespaces. ListAllNamespaces() (namespaces []nsmodel.ID) }
PolicyCacheAPI defines API of PolicyCache used for a non-persistent storage of K8s State data with fast lookups. The cache processes K8s State data updates and RESYNC events through Update() and Resync() APIs, respectively. The cache allows to get notified about changes via convenient callbacks. A watcher needs to implement the interface PolicyCacheWatcher and subscribe for watching using Watch() API. The cache provides various fast lookup methods (e.g. by the label selector).
type PolicyCacheWatcher ¶
type PolicyCacheWatcher interface { // Resync is called by Policy Cache during a RESYNC event. Resync(data *DataResyncEvent) error // AddPod is called by Policy Cache when a new pod is created. AddPod(pod *podmodel.Pod) error // DelPod is called by Policy Cache after a pod was removed. DelPod(pod *podmodel.Pod) error // UpdatePod is called by Policy Cache when data of a pod were modified. UpdatePod(oldPod, newPod *podmodel.Pod) error // AddPolicy is called by Policy Cache when a new policy is created. AddPolicy(policy *policymodel.Policy) error // DelPolicy is called by Policy Cache after a policy was removed. DelPolicy(policy *policymodel.Policy) error // UpdatePolicy is called by Policy Cache when date of a policy were // modified. UpdatePolicy(oldPolicy, newPolicy *policymodel.Policy) error // AddNamespace is called by Policy Cache when a new namespace is created. AddNamespace(ns *nsmodel.Namespace) error // DelNamespace is called by Policy Cache after a namespace was removed. DelNamespace(ns *nsmodel.Namespace) error // UpdateNamespace is called by Policy Cache when data of a namespace were // modified. UpdateNamespace(oldNs, newNs *nsmodel.Namespace) error }
PolicyCacheWatcher defines interface that a PolicyCache watcher must implement.