Documentation ¶
Index ¶
- Constants
- Variables
- func IndexerPlugin(name string, c IndexerConstructor) map[string][]interface{}
- func MatcherPlugin(name string, m MatcherConstructor) map[string][]interface{}
- type Container
- type ContainerIndexer
- type ContainerPort
- type Enabled
- type FieldMatcher
- type GenDefaultMeta
- type GenMeta
- type Indexer
- type IndexerConstructor
- type Indexers
- type Matcher
- type MatcherConstructor
- type Matchers
- type MetadataIndex
- type NodeOption
- type ObjectMeta
- type PluginConfig
- type Pod
- type PodContainerStatus
- type PodNameIndexer
- type PodSpec
- type PodStatus
- type PodStatusCondition
- type PodWatcher
- type Register
- func (r *Register) AddDefaultIndexerConfig(name string, config common.Config)
- func (r *Register) AddDefaultMatcherConfig(name string, config common.Config)
- func (r *Register) AddIndexer(name string, indexer IndexerConstructor)
- func (r *Register) AddMatcher(name string, matcher MatcherConstructor)
- func (r *Register) GetIndexer(name string) IndexerConstructor
- func (r *Register) GetMatcher(name string) MatcherConstructor
Constants ¶
const ( PodNameIndexerName = "pod_name" FieldMatcherName = "fields" ContainerIndexerName = "container" )
Names of indexers and matchers that have been defined.
Variables ¶
var Indexing = NewRegister()
Indexing is the singleton Register instance where all Indexers and Matchers are stored
Functions ¶
func IndexerPlugin ¶
func IndexerPlugin(name string, c IndexerConstructor) map[string][]interface{}
func MatcherPlugin ¶
func MatcherPlugin(name string, m MatcherConstructor) map[string][]interface{}
Types ¶
type Container ¶
type Container struct { Image string `json:"image"` ImagePullPolicy string `json:"imagePullPolicy"` Name string `json:"name"` Ports []ContainerPort `json:"ports"` Resources struct{} `json:"resources"` TerminationMessagePath string `json:"terminationMessagePath"` VolumeMounts []struct { MountPath string `json:"mountPath"` Name string `json:"name"` ReadOnly bool `json:"readOnly"` } `json:"volumeMounts"` }
type ContainerIndexer ¶
type ContainerIndexer struct {
// contains filtered or unexported fields
}
ContainerIndexer indexes pods based on all their containers IDs
func (*ContainerIndexer) GetIndexes ¶
func (c *ContainerIndexer) GetIndexes(pod *Pod) []string
func (*ContainerIndexer) GetMetadata ¶
func (c *ContainerIndexer) GetMetadata(pod *Pod) []MetadataIndex
type ContainerPort ¶
type FieldMatcher ¶
type FieldMatcher struct {
MatchFields []string
}
func (*FieldMatcher) MetadataIndex ¶
func (f *FieldMatcher) MetadataIndex(event common.MapStr) string
type GenDefaultMeta ¶
type GenDefaultMeta struct {
// contains filtered or unexported fields
}
func (*GenDefaultMeta) GenerateMetaData ¶
func (g *GenDefaultMeta) GenerateMetaData(pod *Pod) common.MapStr
GenerateMetaData generates default metadata for the given pod taking to account certain filters
type GenMeta ¶
type GenMeta interface { //GenerateMetaData generates metadata by taking in a pod as an input GenerateMetaData(pod *Pod) common.MapStr }
GenMeta takes in pods to generate metadata for them
type Indexer ¶
type Indexer interface { // GetMetadata generates event metadata for the given pod, then returns the // list of indexes to create, with the metadata to put on them GetMetadata(pod *Pod) []MetadataIndex // GetIndexes return the list of indexes the given pod belongs to. This function // must return the same indexes than GetMetadata GetIndexes(pod *Pod) []string }
Indexer take known pods and generate all the metadata we need to enrich events in a efficient way. By preindexing the metadata in the way it will be checked when matching events
func NewContainerIndexer ¶
type IndexerConstructor ¶
type Indexers ¶
func (*Indexers) GetIndexes ¶
GetIndexes returns the composed index list from all registered indexers
func (*Indexers) GetMetadata ¶
func (i *Indexers) GetMetadata(pod *Pod) []MetadataIndex
GetMetadata returns the composed metadata list from all registered indexers
type Matcher ¶
type Matcher interface { // MetadataIndex returns the index string to use in annotation lookups for the given // event. A previous indexer should have generated that index for this to work // This function can return "" if the event doesn't match MetadataIndex(event common.MapStr) string }
Matcher takes a new event and returns the index
type MetadataIndex ¶
MetadataIndex holds a pair of index -> metadata info
type NodeOption ¶
type NodeOption struct{}
type ObjectMeta ¶
type ObjectMeta struct { Annotations map[string]string `json:"annotations"` CreationTimestamp string `json:"creationTimestamp"` DeletionTimestamp string `json:"deletionTimestamp"` GenerateName string `json:"generateName"` Labels map[string]string `json:"labels"` Name string `json:"name"` Namespace string `json:"namespace"` OwnerReferences []struct { APIVersion string `json:"apiVersion"` Controller bool `json:"controller"` Kind string `json:"kind"` Name string `json:"name"` UID string `json:"uid"` } `json:"ownerReferences"` ResourceVersion string `json:"resourceVersion"` SelfLink string `json:"selfLink"` UID string `json:"uid"` }
type PluginConfig ¶
type Pod ¶
type Pod struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata ObjectMeta `json:"metadata"` Spec PodSpec `json:"spec"` Status PodStatus `json:"status"` }
type PodContainerStatus ¶
type PodContainerStatus struct { ContainerID string `json:"containerID"` Image string `json:"image"` ImageID string `json:"imageID"` LastState struct { Terminated struct { ContainerID string `json:"containerID"` ExitCode int64 `json:"exitCode"` FinishedAt string `json:"finishedAt"` Reason string `json:"reason"` StartedAt string `json:"startedAt"` } `json:"terminated"` } `json:"lastState"` Name string `json:"name"` Ready bool `json:"ready"` RestartCount int64 `json:"restartCount"` State struct { Running struct { StartedAt string `json:"startedAt"` } `json:"running"` } `json:"state"` }
type PodNameIndexer ¶
type PodNameIndexer struct {
// contains filtered or unexported fields
}
PodNameIndexer implements default indexer based on pod name
func (*PodNameIndexer) GetIndexes ¶
func (p *PodNameIndexer) GetIndexes(pod *Pod) []string
func (*PodNameIndexer) GetMetadata ¶
func (p *PodNameIndexer) GetMetadata(pod *Pod) []MetadataIndex
type PodSpec ¶
type PodSpec struct { Containers []Container `json:"containers"` DNSPolicy string `json:"dnsPolicy"` NodeName string `json:"nodeName"` RestartPolicy string `json:"restartPolicy"` SecurityContext struct{} `json:"securityContext"` ServiceAccount string `json:"serviceAccount"` ServiceAccountName string `json:"serviceAccountName"` TerminationGracePeriodSeconds int64 `json:"terminationGracePeriodSeconds"` }
type PodStatus ¶
type PodStatus struct { Conditions []PodStatusCondition `json:"conditions"` ContainerStatuses []PodContainerStatus `json:"containerStatuses"` HostIP string `json:"hostIP"` Phase string `json:"phase"` PodIP string `json:"podIP"` StartTime string `json:"startTime"` }
type PodStatusCondition ¶
type PodWatcher ¶
type PodWatcher struct {
// contains filtered or unexported fields
}
PodWatcher is a controller that synchronizes Pods.
func NewPodWatcher ¶
func NewPodWatcher(kubeClient *k8s.Client, indexers *Indexers, syncPeriod time.Duration, host string) *PodWatcher
NewPodWatcher initializes the watcher client to provide a local state of pods from the cluster (filtered to the given host)
func (*PodWatcher) GetMetaData ¶
func (p *PodWatcher) GetMetaData(arg string) common.MapStr
func (*PodWatcher) GetPod ¶
func (p *PodWatcher) GetPod(uid string) *Pod
func (*PodWatcher) Run ¶
func (p *PodWatcher) Run() bool
func (*PodWatcher) Stop ¶
func (p *PodWatcher) Stop()
type Register ¶
Register contains Indexer and Matchers to use on pod indexing and event matching
func (*Register) AddDefaultIndexerConfig ¶
AddIndexer to the register
func (*Register) AddDefaultMatcherConfig ¶
AddMatcher to the register
func (*Register) AddIndexer ¶
func (r *Register) AddIndexer(name string, indexer IndexerConstructor)
AddIndexer to the register
func (*Register) AddMatcher ¶
func (r *Register) AddMatcher(name string, matcher MatcherConstructor)
AddMatcher to the register
func (*Register) GetIndexer ¶
func (r *Register) GetIndexer(name string) IndexerConstructor
AddIndexer to the register
func (*Register) GetMatcher ¶
func (r *Register) GetMatcher(name string) MatcherConstructor
AddMatcher to the register