beats: github.com/elastic/beats/libbeat/common/kubernetes Index | Files

package kubernetes

import "github.com/elastic/beats/libbeat/common/kubernetes"

Index

Package Files

eventhandler.go metadata.go types.go util.go watcher.go

func ContainerID Uses

func ContainerID(s PodContainerStatus) string

ContainerID parses the container ID to get the actual ID string

func ContainerIDWithRuntime Uses

func ContainerIDWithRuntime(s PodContainerStatus) (string, string)

ContainerIDWithRuntime parses the container ID to get the actual ID string

func DiscoverKubernetesNode Uses

func DiscoverKubernetesNode(host string, inCluster bool, client kubernetes.Interface) (node string)

DiscoverKubernetesNode figures out the Kubernetes node to use. If host is provided in the config use it directly. If beat is deployed in k8s cluster, use hostname of pod which is pod name to query pod meta for node name. If beat is deployed outside k8s cluster, use machine-id to match against k8s nodes for node name.

func GetKubernetesClient Uses

func GetKubernetesClient(kubeconfig string) (kubernetes.Interface, error)

GetKubernetesClient returns a kubernetes client. If inCluster is true, it returns an in cluster configuration based on the secrets mounted in the Pod. If kubeConfig is passed, it parses the config file to get the config required to build a client.

func IsInCluster Uses

func IsInCluster(kubeconfig string) bool

IsInCluster takes a kubeconfig file path as input and deduces if Beats is running in cluster or not, taking into consideration the existence of KUBECONFIG variable

func Time Uses

func Time(t *metav1.Time) time.Time

Time extracts time from k8s.Time type

type Container Uses

type Container = v1.Container

Container data

type ContainerPort Uses

type ContainerPort = v1.ContainerPort

ContainerPort data

type Deployment Uses

type Deployment = appsv1.Deployment

Deployment data

type Event Uses

type Event = v1.Event

Event data

type FilteringResourceEventHandler Uses

type FilteringResourceEventHandler struct {
    FilterFunc func(obj interface{}) bool
    Handler    ResourceEventHandler
}

FilteringResourceEventHandler applies the provided filter to all events coming in, ensuring the appropriate nested handler method is invoked. An object that starts passing the filter after an update is considered an add, and an object that stops passing the filter after an update is considered a delete.

func (FilteringResourceEventHandler) OnAdd Uses

func (r FilteringResourceEventHandler) OnAdd(obj interface{})

OnAdd calls the nested handler only if the filter succeeds

func (FilteringResourceEventHandler) OnDelete Uses

func (r FilteringResourceEventHandler) OnDelete(obj interface{})

OnDelete calls the nested handler only if the filter succeeds

func (FilteringResourceEventHandler) OnUpdate Uses

func (r FilteringResourceEventHandler) OnUpdate(obj interface{})

OnUpdate ensures the proper handler is called depending on whether the filter matches

type MetaGenerator Uses

type MetaGenerator interface {
    // ResourceMetadata generates metadata for the given kubernetes object taking to account certain filters
    ResourceMetadata(obj Resource) common.MapStr

    // PodMetadata generates metadata for the given pod taking to account certain filters
    PodMetadata(pod *Pod) common.MapStr

    // Containermetadata generates metadata for the given container of a pod
    ContainerMetadata(pod *Pod, container string, image string) common.MapStr
}

MetaGenerator builds metadata objects for pods and containers

func NewMetaGenerator Uses

func NewMetaGenerator(cfg *common.Config) (MetaGenerator, error)

NewMetaGenerator initializes and returns a new kubernetes metadata generator

func NewMetaGeneratorFromConfig Uses

func NewMetaGeneratorFromConfig(cfg *MetaGeneratorConfig) MetaGenerator

NewMetaGeneratorFromConfig initializes and returns a new kubernetes metadata generator

type MetaGeneratorConfig Uses

type MetaGeneratorConfig struct {
    IncludeLabels      []string `config:"include_labels"`
    ExcludeLabels      []string `config:"exclude_labels"`
    IncludeAnnotations []string `config:"include_annotations"`

    LabelsDedot      bool `config:"labels.dedot"`
    AnnotationsDedot bool `config:"annotations.dedot"`

    // Undocumented settings, to be deprecated in favor of `drop_fields` processor:
    IncludeCreatorMetadata bool `config:"include_creator_metadata"`
}

MetaGeneratorConfig settings

func DefaultMetaGeneratorConfig Uses

func DefaultMetaGeneratorConfig() MetaGeneratorConfig

DefaultMetaGeneratorConfig initializes and returns a new MetaGeneratorConfig with default values

type Node Uses

type Node = v1.Node

Node data

type ObjectMeta Uses

type ObjectMeta = metav1.ObjectMeta

ObjectMeta data

type Pod Uses

type Pod = v1.Pod

Pod data

type PodContainerStatus Uses

type PodContainerStatus = v1.ContainerStatus

PodContainerStatus data

type PodSpec Uses

type PodSpec = v1.PodSpec

PodSpec data

type PodStatus Uses

type PodStatus = v1.PodStatus

PodStatus data

type ReplicaSet Uses

type ReplicaSet = extv1.ReplicaSet

ReplicaSet data

type Resource Uses

type Resource = runtime.Object

Resource data

type ResourceEventHandler Uses

type ResourceEventHandler interface {
    OnAdd(obj interface{})
    OnUpdate(obj interface{})
    OnDelete(obj interface{})
}

ResourceEventHandler can handle notifications for events that happen to a resource. The events are informational only, so you can't return an error.

* OnAdd is called when an object is added.
* OnUpdate is called when an object is modified. Note that oldObj is the
    last known state of the object-- it is possible that several changes
    were combined together, so you can't use this to see every single
    change. OnUpdate is also called when a re-list happens, and it will
    get called even if nothing changed. This is useful for periodically
    evaluating or syncing something.
* OnDelete will get the final state of the item if it is known, otherwise
    it will get an object of type DeletedFinalStateUnknown. This can
    happen if the watch is closed and misses the delete event and we don't
    notice the deletion until the subsequent re-list.

TODO: allow the On* methods to return an error so that the RateLimited WorkQueue TODO: can requeue the failed event processing.

type ResourceEventHandlerFuncs Uses

type ResourceEventHandlerFuncs struct {
    AddFunc    func(obj interface{})
    UpdateFunc func(obj interface{})
    DeleteFunc func(obj interface{})
}

ResourceEventHandlerFuncs is an adaptor to let you easily specify as many or as few of the notification functions as you want while still implementing ResourceEventHandler.

func (ResourceEventHandlerFuncs) OnAdd Uses

func (r ResourceEventHandlerFuncs) OnAdd(obj interface{})

OnAdd calls AddFunc if it's not nil.

func (ResourceEventHandlerFuncs) OnDelete Uses

func (r ResourceEventHandlerFuncs) OnDelete(obj interface{})

OnDelete calls DeleteFunc if it's not nil.

func (ResourceEventHandlerFuncs) OnUpdate Uses

func (r ResourceEventHandlerFuncs) OnUpdate(obj interface{})

OnUpdate calls UpdateFunc if it's not nil.

type StatefulSet Uses

type StatefulSet = appsv1.StatefulSet

StatefulSet data

type WatchOptions Uses

type WatchOptions struct {
    // SyncTimeout is a timeout for listing historical resources
    SyncTimeout time.Duration
    // Node is used for filtering watched resource to given node, use "" for all nodes
    Node string
    // Namespace is used for filtering watched resource to given namespace, use "" for all namespaces
    Namespace string
}

WatchOptions controls watch behaviors

type Watcher Uses

type Watcher interface {
    // Start watching Kubernetes API for new events after resources were listed
    Start() error

    // Stop watching Kubernetes API for new events
    Stop()

    // AddEventHandler add event handlers for corresponding event type watched
    AddEventHandler(ResourceEventHandler)
}

Watcher watches Kubernetes resources events

func NewWatcher Uses

func NewWatcher(client kubernetes.Interface, resource Resource, opts WatchOptions) (Watcher, error)

NewWatcher initializes the watcher client to provide a events handler for resource from the cluster (filtered to the given node)

Package kubernetes imports 22 packages (graph) and is imported by 112 packages. Updated 2019-10-11. Refresh now. Tools for package owners.