controller

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(kind string) func(obj interface{}) bool

Filter makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on the kind of the controlling resources.

func GetK8sServiceFullname

func GetK8sServiceFullname(name string, namespace string) string

func GetRevisionHeaderName

func GetRevisionHeaderName() string

func GetRevisionHeaderNamespace

func GetRevisionHeaderNamespace() string

func GetServingK8SServiceNameForObj

func GetServingK8SServiceNameForObj(name string) string

func NewControllerRef

func NewControllerRef(obj metav1.Object) *metav1.OwnerReference

NewControllerRef creates an OwnerReference pointing to the given Resource.

func PassNew

func PassNew(f func(interface{})) func(interface{}, interface{})

PassNew makes it simple to create an UpdateFunc for use with cache.ResourceEventHandlerFuncs that can delegate the same methods as AddFunc/DeleteFunc but passing through only the second argument (which is the "new" object).

Types

type Base

type Base struct {
	// KubeClientSet allows us to talk to the k8s for core APIs
	KubeClientSet kubernetes.Interface

	// ServingClientSet allows us to configure Serving objects
	ServingClientSet clientset.Interface

	// BuildClientSet allows us to configure Build objects
	BuildClientSet buildclientset.Interface

	// ConfigMapWatcher allows us to watch for ConfigMap changes.
	ConfigMapWatcher configmap.Watcher

	// Recorder is an event recorder for recording Event resources to the
	// Kubernetes API.
	Recorder record.EventRecorder

	// WorkQueue is a rate limited work queue. This is used to queue work to be
	// processed instead of performing it as soon as a change happens. This
	// means we can ensure we only process a fixed amount of resources at a
	// time, and makes it easy to ensure we are never processing the same item
	// simultaneously in two different workers.
	WorkQueue workqueue.RateLimitingInterface

	// Sugared logger is easier to use but is not as performant as the
	// raw logger. In performance critical paths, call logger.Desugar()
	// and use the returned raw logger instead. In addition to the
	// performance benefits, raw logger also preserves type-safety at
	// the expense of slightly greater verbosity.
	Logger *zap.SugaredLogger
}

Base implements most of the boilerplate and common code we have in our controllers.

func NewBase

func NewBase(opt Options, controllerAgentName, workQueueName string) *Base

NewBase instantiates a new instance of Base implementing the common & boilerplate code between our controllers.

func (*Base) Enqueue

func (c *Base) Enqueue(obj interface{})

Enqueue takes a resource and converts it into a namespace/name string which is then put onto the work queue.

func (*Base) EnqueueControllerOf

func (c *Base) EnqueueControllerOf(obj interface{})

EnqueueControllerOf takes a resource, identifies its controller resource, and converts it into a namespace/name string which is then put onto the work queue.

func (*Base) EnqueueKey

func (c *Base) EnqueueKey(key string)

EnqueueKey takes a namespace/name string and puts it onto the work queue.

func (*Base) GetWorkQueue

func (b *Base) GetWorkQueue() workqueue.RateLimitingInterface

GetWorkQueue helps implement Interface for derivatives.

func (*Base) RunController

func (c *Base) RunController(
	threadiness int,
	stopCh <-chan struct{},
	syncHandler func(string) error,
	controllerName string) error

RunController starts the controller's worker threads, the number of which is threadiness. It then blocks until stopCh is closed, at which point it shuts down its internal work queue and waits for workers to finish processing their current work items.

type Interface

type Interface interface {
	Run(threadiness int, stopCh <-chan struct{}) error
	Reconcile(key string) error
	GetWorkQueue() workqueue.RateLimitingInterface
}

Interface defines the controller interface

type Options

type Options struct {
	KubeClientSet    kubernetes.Interface
	ServingClientSet clientset.Interface
	BuildClientSet   buildclientset.Interface
	ConfigMapWatcher configmap.Watcher
	Logger           *zap.SugaredLogger
}

Options defines the common controller options passed to NewBase. We define this to reduce the boilerplate argument list when creating derivative controllers.

Directories

Path Synopsis
resources
Package resources holds simple functions for synthesizing child resources from a Configuration resource and any relevant Configuration controller configuration.
Package resources holds simple functions for synthesizing child resources from a Configuration resource and any relevant Configuration controller configuration.
resources/names
Package names holds simple functions for synthesizing resource names.
Package names holds simple functions for synthesizing resource names.
config
Package config holds the typed objects that define the schemas for assorted ConfigMap objects on which the Revision controller depends.
Package config holds the typed objects that define the schemas for assorted ConfigMap objects on which the Revision controller depends.
resources
Package resources holds simple functions for synthesizing child resources from a Revision resource and any relevant Revision controller configuration.
Package resources holds simple functions for synthesizing child resources from a Revision resource and any relevant Revision controller configuration.
resources/names
Package names holds simple functions for synthesizing resource names.
Package names holds simple functions for synthesizing resource names.
config
Package config holds the typed objects that define the schemas for assorted ConfigMap objects on which the Route controller depends.
Package config holds the typed objects that define the schemas for assorted ConfigMap objects on which the Route controller depends.
resources
Package resources holds simple functions for synthesizing child resources from a Route resource and any relevant Route controller configuration.
Package resources holds simple functions for synthesizing child resources from a Route resource and any relevant Route controller configuration.
resources/names
Package names holds simple functions for synthesizing resource names.
Package names holds simple functions for synthesizing resource names.
resources
Package resources holds simple functions for synthesizing child resources from a Service resource and any relevant Service controller configuration.
Package resources holds simple functions for synthesizing child resources from a Service resource and any relevant Service controller configuration.
resources/names
Package names holds simple functions for synthesizing resource names.
Package names holds simple functions for synthesizing resource names.
Package testing includes utilities for testing controllers.
Package testing includes utilities for testing controllers.

Jump to

Keyboard shortcuts

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