watch

package
v0.0.0-...-aab1398 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

Initial work derived from client-go Workqueue Example

This example demonstrates how to write a controller which follows the states of watched resources.

It demonstrates how to:

  • combine the workqueue with a cache to a full controller
  • synchronize the controller on startup

The example is based on https://git.k8s.io/community/contributors/devel/controllers.md.

Running

# if outside of the cluster
go run *.go -kubeconfig=/my/config -logtostderr=true

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug for more verbose output

Functions

func V1TypePointer

func V1TypePointer(watchTypeName K8sAPIName) (v1TypePointer pkgruntime.Object)

V1TypePointer return a valid type pointer derived from the K8sAPIName

Types

type EventType

type EventType string

EventType for watcher

const (
	// ADD EventType
	ADD EventType = "ADD"
	// DELETE EventType
	DELETE EventType = "DELETE"
	// UPDATE EventType
	UPDATE EventType = "UPDATE"
)

type Interface

type Interface interface{}

Interface abstraction for returned type

type K8sAPIName

type K8sAPIName string

K8sAPIName for v1 service types

const (
	// NodeAPIName k8s api name
	NodeAPIName K8sAPIName = "nodes"
	// ServiceAPIName k8s api name
	ServiceAPIName K8sAPIName = "services"
	// EndpointAPIName k8s api name
	EndpointAPIName K8sAPIName = "endpoints"
	// PodAPIName k8s api name
	PodAPIName K8sAPIName = "pods"
)

type QueueController

QueueController allows the creation of multiple independent queue controllers

func NewQueueController

func NewQueueController(typeName K8sAPIName, RateLimitingInterface workqueue.RateLimitingInterface, Indexer cache.Indexer, Controller cache.Controller) *QueueController

NewQueueController creates a watch callback interface

func (*QueueController) Next

func (c *QueueController) Next() bool

Next pushes the event item to it's queue

func (*QueueController) Publish

func (c *QueueController) Publish(event QueueItem) error

Publish is the business logic of the controller publishing to the mgr's service channel.

func (*QueueController) Run

func (c *QueueController) Run(threadiness int, delay time.Duration, stopCh chan struct{})

Run a QueueController to manage a throttled queue of data

type QueueItem

type QueueItem struct {
	Key string
	K8sAPIName
	EventType
	Interface
}

QueueItem publishable object from watch

type QueueItems

type QueueItems chan QueueItem

QueueItems channel for downstream consumption

type QueueMgr

type QueueMgr struct {
	*kubernetes.Clientset
	*cache.ListWatch
	*QueueController
}

QueueMgr abstract the parts of a watcher

func NewQueueMgr

func NewQueueMgr(watchTypeName K8sAPIName, clientset *kubernetes.Clientset) *QueueMgr

NewQueueMgr takes a type string (services, pods, nodes, ...) and a *kubernetes.Clientset, v1TypePointer is the type of the reference object &v1.Service{}, &v1.Node{}...

func NewQueueMgrListOpt

func NewQueueMgrListOpt(watchTypeName K8sAPIName, clientset *kubernetes.Clientset, options *metav1.ListOptions) *QueueMgr

NewQueueMgrListOpt takes a type string (services, pods, nodes, ...) and a *kubernetes.Clientset, v1TypePointer is the type of the reference object &v1.Service{}, &v1.Node{}...

func (*QueueMgr) Run

func (queueMgr *QueueMgr) Run(threadiness, sleepSeconds int)

Run creates a QueueController and executes watchers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL