beats: Index | Files | Directories

package kubernetes

import ""


Package Files

eventhandler.go informer.go types.go util.go watcher.go


const (
    // PodPending phase
    PodPending = v1.PodPending
    // PodRunning phase
    PodRunning = v1.PodRunning
    // PodSucceeded phase
    PodSucceeded = v1.PodSucceeded
    // PodFailed phase
    PodFailed = v1.PodFailed
    // PodUnknown phase
    PodUnknown = v1.PodUnknown

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(log *logp.Logger, 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 NewInformer Uses

func NewInformer(client kubernetes.Interface, resource Resource, opts WatchOptions, indexers cache.Indexers) (cache.SharedInformer, string, error)

NewInformer creates an informer for a given resource

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 Namespace Uses

type Namespace = v1.Namespace

Namespace data

type NoOpEventHandlerFuncs Uses

type NoOpEventHandlerFuncs struct {

NoOpEventHandlerFuncs ensures that watcher reconciliation can happen even without the required funcs

func (NoOpEventHandlerFuncs) OnAdd Uses

func (n NoOpEventHandlerFuncs) OnAdd(obj interface{})

OnAdd does a no-op on an add event

func (NoOpEventHandlerFuncs) OnDelete Uses

func (n NoOpEventHandlerFuncs) OnDelete(obj interface{})

OnDelete does a no-op on a delete event

func (NoOpEventHandlerFuncs) OnUpdate Uses

func (n NoOpEventHandlerFuncs) OnUpdate(obj interface{})

OnUpdate does a no-op on an update event

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 = appsv1.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 Service Uses

type Service = v1.Service

Service data

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

    // AddEventHandler add event handlers for corresponding event type watched

    // Store returns the store object for the watcher
    Store() cache.Store

Watcher watches Kubernetes resources events

func NewWatcher Uses

func NewWatcher(client kubernetes.Interface, resource Resource, opts WatchOptions, indexers cache.Indexers) (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 21 packages (graph) and is imported by 247 packages. Updated 2020-06-07. Refresh now. Tools for package owners.