controller-runtime: sigs.k8s.io/controller-runtime/pkg/source Index | Examples | Files | Directories

package source

import "sigs.k8s.io/controller-runtime/pkg/source"

Package source provides event streams provided to Controllers through Controller.Watch. Events are used with handler.EventHandlers to enqueue reconcile.Requests and trigger Reconciles for Kubernetes objects.

Index

Examples

Package Files

doc.go source.go

type Channel Uses

type Channel struct {

    // Source is the source channel to fetch GenericEvents
    Source <-chan event.GenericEvent

    // DestBufferSize is the specified buffer size of dest channels.
    // Default to 1024 if not specified.
    DestBufferSize int
    // contains filtered or unexported fields
}

Channel is used to provide a source of events originating outside the cluster (e.g. GitHub Webhook callback). Channel requires the user to wire the external source (eh.g. http handler) to write GenericEvents to the underlying channel.

This example reads GenericEvents from a channel and enqueues a reconcile.Request containing the Name and Namespace provided by the event.

Code:

events := make(chan event.GenericEvent)

ctrl.Watch(
    &source.Channel{Source: events},
    &handler.EnqueueRequestForObject{},
)

func (*Channel) InjectStopChannel Uses

func (cs *Channel) InjectStopChannel(stop <-chan struct{}) error

InjectStopChannel is internal should be called only by the Controller. It is used to inject the stop channel initialized by the ControllerManager.

func (*Channel) Start Uses

func (cs *Channel) Start(
    handler handler.EventHandler,
    queue workqueue.RateLimitingInterface,
    prct ...predicate.Predicate) error

Start implements Source and should only be called by the Controller.

func (*Channel) String Uses

func (cs *Channel) String() string

type Func Uses

type Func func(handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error

Func is a function that implements Source

func (Func) Start Uses

func (f Func) Start(evt handler.EventHandler, queue workqueue.RateLimitingInterface,
    pr ...predicate.Predicate) error

Start implements Source

func (Func) String Uses

func (f Func) String() string

type Informer Uses

type Informer struct {
    // Informer is the generated client-go Informer
    Informer toolscache.SharedIndexInformer
}

Informer is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create)

func (*Informer) Start Uses

func (is *Informer) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface,
    prct ...predicate.Predicate) error

Start is internal and should be called only by the Controller to register an EventHandler with the Informer to enqueue reconcile.Requests.

func (*Informer) String Uses

func (is *Informer) String() string

type Kind Uses

type Kind struct {
    // Type is the type of object to watch.  e.g. &v1.Pod{}
    Type runtime.Object
    // contains filtered or unexported fields
}

Kind is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create)

This example Watches for Pod Events (e.g. Create / Update / Delete) and enqueues a reconcile.Request with the Name and Namespace of the Pod.

Code:

ctrl.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{})

func (*Kind) InjectCache Uses

func (ks *Kind) InjectCache(c cache.Cache) error

InjectCache is internal should be called only by the Controller. InjectCache is used to inject the Cache dependency initialized by the ControllerManager.

func (*Kind) Start Uses

func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimitingInterface,
    prct ...predicate.Predicate) error

Start is internal and should be called only by the Controller to register an EventHandler with the Informer to enqueue reconcile.Requests.

func (*Kind) String Uses

func (ks *Kind) String() string

type Source Uses

type Source interface {
    // Start is internal and should be called only by the Controller to register an EventHandler with the Informer
    // to enqueue reconcile.Requests.
    Start(handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error
}

Source is a source of events (eh.g. Create, Update, Delete operations on Kubernetes Objects, Webhook callbacks, etc) which should be processed by event.EventHandlers to enqueue reconcile.Requests.

* Use Kind for events originating in the cluster (e.g. Pod Create, Pod Update, Deployment Update).

* Use Channel for events originating outside the cluster (eh.g. GitHub Webhook callback, Polling external urls).

Users may build their own Source implementations. If their implementations implement any of the inject package interfaces, the dependencies will be injected by the Controller when Watch is called.

Directories

PathSynopsis
internal

Package source imports 13 packages (graph) and is imported by 48 packages. Updated 2018-12-06. Refresh now. Tools for package owners.