controller

package
v0.0.0-...-ea02baa Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromLabelValueInvalid = "invalid"
	PromLabelValueSuccess = "success"
	PromLabelValueFailure = "failure"
)

Standard labels and values to use in Prometheus metrics.

Variables

This section is empty.

Functions

func GetDomainConfigMapName

func GetDomainConfigMapName() string

func GetElaK8SActivatorNamespace

func GetElaK8SActivatorNamespace() string

func GetElaK8SActivatorServiceName

func GetElaK8SActivatorServiceName() string

func GetElaK8SIngressName

func GetElaK8SIngressName(u *v1alpha1.Route) string

func GetElaK8SServiceName

func GetElaK8SServiceName(u *v1alpha1.Route) string

func GetElaK8SServiceNameForRevision

func GetElaK8SServiceNameForRevision(u *v1alpha1.Revision) string

func GetElaNamespaceName

func GetElaNamespaceName(ns string) string

Various functions for naming the resources for consistency

func GetOrCreateNamespace

func GetOrCreateNamespace(ctx context.Context, namespace string, c clientset.Interface) (string, error)

func GetOrCreateRevisionNamespace

func GetOrCreateRevisionNamespace(ctx context.Context, ns string, c clientset.Interface) (string, error)

func GetRevisionAutoscalerName

func GetRevisionAutoscalerName(u *v1alpha1.Revision) string

func GetRevisionDeploymentName

func GetRevisionDeploymentName(u *v1alpha1.Revision) string

func GetRevisionHeaderName

func GetRevisionHeaderName() string

func GetRevisionHeaderNamespace

func GetRevisionHeaderNamespace() string

func GetRouteRuleName

func GetRouteRuleName(u *v1alpha1.Route, tt *v1alpha1.TrafficTarget) string

func LookupOwningConfigurationName

func LookupOwningConfigurationName(ownerRefs []v1.OwnerReference) string

LookupOwningConfigurationName returns the name of Configuration as OwnerReference if there is any in the given OwnerReference array.

func LookupOwningRouteName

func LookupOwningRouteName(ownerRefs []v1.OwnerReference) string

LookupOwningRouteName returns the name of Route as OwnerReference if there is any in the given OwnerReference array.

func NewConfigurationControllerRef

func NewConfigurationControllerRef(config *v1alpha1.Configuration) *metav1.OwnerReference

NewConfigurationControllerRef creates an OwnerReference pointing to the given Service.

func NewRevisionControllerRef

func NewRevisionControllerRef(rev *v1alpha1.Revision) *metav1.OwnerReference

NewRevisionControllerRef creates an OwnerReference pointing to the given Service.

func NewRouteControllerRef

func NewRouteControllerRef(route *v1alpha1.Route) *metav1.OwnerReference

NewRouteControllerRef creates an OwnerReference pointing to the given Service.

func NewServiceControllerRef

func NewServiceControllerRef(service *v1alpha1.Service) *metav1.OwnerReference

NewServiceControllerRef creates an OwnerReference pointing to the given Service.

Types

type Base

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

	// ElaClientSet allows us to configure Ela objects
	ElaClientSet clientset.Interface

	// KubeInformerFactory provides shared informers for resources
	// in all known API group versions
	KubeInformerFactory kubeinformers.SharedInformerFactory

	// ElaInformerFactory provides shared informers for resources
	// in all known API group versions
	ElaInformerFactory informers.SharedInformerFactory

	// 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(
	kubeClientSet kubernetes.Interface,
	elaClientSet clientset.Interface,
	kubeInformerFactory kubeinformers.SharedInformerFactory,
	elaInformerFactory informers.SharedInformerFactory,
	informer cache.SharedIndexInformer,
	controllerAgentName string,
	workQueueName string,
	logger *zap.SugaredLogger) *Base

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

func (*Base) RunController

func (c *Base) RunController(
	threadiness int,
	stopCh <-chan struct{},
	informersSynced []cache.InformerSynced,
	syncHandler func(string) error,
	controllerName string) error

RunController will set up the event handlers for types we are interested in, as well as syncing informer caches and starting workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers to finish processing their current work items.

type Config

type Config struct {
	// Domains map from domain to label selector.  If a route has
	// labels matching a particular selector, it will use the
	// corresponding domain.  If multiple selectors match, we choose
	// the most specific selector.
	Domains map[string]*LabelSelector
}

Config contains controller configurations.

func NewConfig

func NewConfig(kubeClient kubernetes.Interface) (*Config, error)

func (*Config) LookupDomainForLabels

func (c *Config) LookupDomainForLabels(labels map[string]string) string

LookupDomainForLabels() returns a domain given a set of labels. Since we reject configuration without a default domain, this should always return a value.

type Interface

type Interface interface {
	Run(threadiness int, stopCh <-chan struct{}) error
}

Interface defines the controller interface

type LabelSelector

type LabelSelector struct {
	Selector map[string]string `json:"selector,omitempty"`
}

LabelSelector represents map of {key,value} pairs. A single {key,value} in the map is equivalent to a requirement key == value. The requirements are ANDed.

func (*LabelSelector) Matches

func (s *LabelSelector) Matches(labels map[string]string) bool

Matches() returns whether the given labels meet the requirement of the selector.

Directories

Path Synopsis
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