controller

package
v3.7.19-1+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package controller contains the router controller.

Index

Constants

This section is empty.

Variables

View Source
var LogRejections = logRecorder{}

Functions

func GetNameForHost added in v1.5.0

func GetNameForHost(name string) string

GetNameForHost returns the name of the ingress if the route name was generated from a path, otherwise it returns the name as given.

func GetSafeRouteName added in v1.5.0

func GetSafeRouteName(name string) string

GetSafeRouteName returns a name that is safe for use in an HAproxy config.

func HostForRoute added in v1.0.6

func HostForRoute(route *routeapi.Route) string

HostForRoute returns the host set on the route.

func IsGeneratedRouteName added in v1.5.0

func IsGeneratedRouteName(name string) bool

IsGeneratedRoute indicates whether the given route name was generated from an ingress.

Types

type ExtendedValidator added in v1.3.0

type ExtendedValidator struct {
	// contains filtered or unexported fields
}

ExtendedValidator implements the router.Plugin interface to provide extended config validation for template based, backend-agnostic routers.

func NewExtendedValidator added in v1.3.0

func NewExtendedValidator(plugin router.Plugin, recorder RejectionRecorder) *ExtendedValidator

NewExtendedValidator creates a plugin wrapper that ensures only routes that pass extended validation are relayed to the next plugin in the chain. Recorder is an interface for indicating why a route was rejected.

func (*ExtendedValidator) Commit added in v1.5.0

func (p *ExtendedValidator) Commit() error

func (*ExtendedValidator) HandleEndpoints added in v1.3.0

func (p *ExtendedValidator) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error

HandleEndpoints processes watch events on the Endpoints resource.

func (*ExtendedValidator) HandleNamespaces added in v1.3.0

func (p *ExtendedValidator) HandleNamespaces(namespaces sets.String) error

HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.

func (*ExtendedValidator) HandleNode added in v1.4.0

func (p *ExtendedValidator) HandleNode(eventType watch.EventType, node *kapi.Node) error

HandleNode processes watch events on the node resource

func (*ExtendedValidator) HandleRoute added in v1.3.0

func (p *ExtendedValidator) HandleRoute(eventType watch.EventType, route *routeapi.Route) error

HandleRoute processes watch events on the Route resource.

type HostAdmitter added in v1.4.0

type HostAdmitter struct {
	// contains filtered or unexported fields
}

HostAdmitter implements the router.Plugin interface to add admission control checks for routes in template based, backend-agnostic routers.

func NewHostAdmitter added in v1.4.0

func NewHostAdmitter(plugin router.Plugin, fn RouteAdmissionFunc, allowWildcards, disableNamespaceCheck bool, recorder RejectionRecorder) *HostAdmitter

NewHostAdmitter creates a plugin wrapper that checks whether or not to admit routes and relay them to the next plugin in the chain. Recorder is an interface for indicating why a route was rejected.

func (*HostAdmitter) Commit added in v1.5.0

func (p *HostAdmitter) Commit() error

func (*HostAdmitter) HandleEndpoints added in v1.4.0

func (p *HostAdmitter) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error

HandleEndpoints processes watch events on the Endpoints resource.

func (*HostAdmitter) HandleNamespaces added in v1.4.0

func (p *HostAdmitter) HandleNamespaces(namespaces sets.String) error

HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.

func (*HostAdmitter) HandleNode added in v1.4.0

func (p *HostAdmitter) HandleNode(eventType watch.EventType, node *kapi.Node) error

HandleNode processes watch events on the Node resource.

func (*HostAdmitter) HandleRoute added in v1.4.0

func (p *HostAdmitter) HandleRoute(eventType watch.EventType, route *routeapi.Route) error

HandleRoute processes watch events on the Route resource.

type HostToRouteMap added in v1.0.6

type HostToRouteMap map[string][]*routeapi.Route

type IngressTranslator added in v1.5.0

type IngressTranslator struct {
	// contains filtered or unexported fields
}

IngressTranslator converts secret and ingress events into route events.

- Caches ingresses to enable:

  • Identification of which secrets are referenced by ingresses
  • Generation of route events in response to a secret event
  • Route deletion when an ingress rule is removed

- Caches secrets to minimize the lookups required to generate route events from an ingress

  • Secrets will be read into the cache via Get() the first time they are referenced
  • Only secrets referenced by an ingress cached by the router will themselves be cached
  • Secrets will be updated by calls to TranslateSecretEvent

func NewIngressTranslator added in v1.5.0

func NewIngressTranslator(kc kcoreclient.SecretsGetter) *IngressTranslator

NewIngressTranslator creates a new cache for the given client

func (*IngressTranslator) TranslateIngressEvent added in v1.5.0

func (it *IngressTranslator) TranslateIngressEvent(eventType watch.EventType, ingress *extensions.Ingress) []ingressRouteEvents

TranslateIngressEvent converts an ingress event into route events.

func (*IngressTranslator) TranslateSecretEvent added in v1.5.0

func (it *IngressTranslator) TranslateSecretEvent(eventType watch.EventType, secret *kapi.Secret) (events []ingressRouteEvents)

TranslateSecretEvent converts the given secret event into route events.

func (*IngressTranslator) UpdateNamespaces added in v1.5.0

func (it *IngressTranslator) UpdateNamespaces(namespaces sets.String)

UpdateNamespaces sets which namespaces ingress objects are allowed from and updates the cache accordingly.

type RejectionRecorder added in v1.1.3

type RejectionRecorder interface {
	RecordRouteRejection(route *routeapi.Route, reason, message string)
}

RejectionRecorder is an object capable of recording why a route was rejected

type RouteAdmissionFunc added in v1.4.0

type RouteAdmissionFunc func(*routeapi.Route) error

RouteAdmissionFunc determines whether or not to admit a route.

type RouteHostFunc added in v1.0.6

type RouteHostFunc func(*routeapi.Route) string

RouteHostFunc returns a host for a route. It may return an empty string.

type RouteMap added in v1.4.0

type RouteMap map[string][]*routeapi.Route

RouteMap contains all routes associated with a key

func (RouteMap) InsertRoute added in v1.4.0

func (srm RouteMap) InsertRoute(key string, route *routeapi.Route)

func (RouteMap) RemoveRoute added in v1.4.0

func (srm RouteMap) RemoveRoute(key string, route *routeapi.Route) bool

RemoveRoute removes any existing routes that match the given route's namespace and name for a key

type RouteToHostMap added in v1.0.6

type RouteToHostMap map[string]string

type RouterController

type RouterController struct {
	Plugin router.Plugin

	FilteredNamespaceNames sets.String
	NamespaceLabels        labels.Selector
	// Holds Namespace --> RouteName --> RouteObject
	NamespaceRoutes map[string]map[string]*routeapi.Route
	// Holds Namespace --> EndpointsName --> EndpointsObject
	NamespaceEndpoints map[string]map[string]*kapi.Endpoints

	ProjectClient       projectclient.ProjectResourceInterface
	ProjectLabels       labels.Selector
	ProjectSyncInterval time.Duration
	ProjectWaitInterval time.Duration
	ProjectRetries      int

	WatchNodes bool

	EnableIngress     bool
	IngressTranslator *IngressTranslator
	// contains filtered or unexported fields
}

RouterController abstracts the details of watching resources like Routes, Endpoints, etc. used by the plugin implementation.

func (*RouterController) Commit

func (c *RouterController) Commit()

Commit notifies the plugin that it is safe to commit state.

func (*RouterController) GetFilteredProjectNames

func (c *RouterController) GetFilteredProjectNames() (sets.String, error)

func (*RouterController) HandleEndpoints

func (c *RouterController) HandleEndpoints(eventType watch.EventType, obj interface{})

HandleEndpoints handles a single Endpoints event and refreshes the router backend.

func (*RouterController) HandleIngress added in v1.5.0

func (c *RouterController) HandleIngress(eventType watch.EventType, obj interface{})

HandleIngress handles a single Ingress event and synchronizes the router backend.

func (*RouterController) HandleNamespace

func (c *RouterController) HandleNamespace(eventType watch.EventType, obj interface{})

func (*RouterController) HandleNode added in v1.4.0

func (c *RouterController) HandleNode(eventType watch.EventType, obj interface{})

HandleNode handles a single Node event and synchronizes the router backend

func (*RouterController) HandleProjects

func (c *RouterController) HandleProjects()

func (*RouterController) HandleRoute

func (c *RouterController) HandleRoute(eventType watch.EventType, obj interface{})

HandleRoute handles a single Route event and synchronizes the router backend.

func (*RouterController) HandleSecret added in v1.5.0

func (c *RouterController) HandleSecret(eventType watch.EventType, obj interface{})

HandleSecret handles a single Secret event and synchronizes the router backend.

func (*RouterController) RecordNamespaceEndpoints

func (c *RouterController) RecordNamespaceEndpoints(eventType watch.EventType, ep *kapi.Endpoints)

func (*RouterController) RecordNamespaceRoutes

func (c *RouterController) RecordNamespaceRoutes(eventType watch.EventType, rt *routeapi.Route)

func (*RouterController) Run

func (c *RouterController) Run()

Run begins watching and syncing.

func (*RouterController) UpdateNamespaces

func (c *RouterController) UpdateNamespaces()

type StatusAdmitter added in v1.1.3

type StatusAdmitter struct {
	// contains filtered or unexported fields
}

StatusAdmitter ensures routes added to the plugin have status set.

func NewStatusAdmitter added in v1.1.3

func NewStatusAdmitter(plugin router.Plugin, client client.RoutesGetter, name, hostName string) *StatusAdmitter

NewStatusAdmitter creates a plugin wrapper that ensures every accepted route has a status field set that matches this router. The admitter manages an LRU of recently seen conflicting updates to handle when two router processes with differing configurations are writing updates at the same time.

func (*StatusAdmitter) Commit added in v1.5.0

func (a *StatusAdmitter) Commit() error

func (*StatusAdmitter) HandleEndpoints added in v1.1.3

func (a *StatusAdmitter) HandleEndpoints(eventType watch.EventType, route *kapi.Endpoints) error

func (*StatusAdmitter) HandleNamespaces added in v1.1.3

func (a *StatusAdmitter) HandleNamespaces(namespaces sets.String) error

func (*StatusAdmitter) HandleNode added in v1.4.0

func (a *StatusAdmitter) HandleNode(eventType watch.EventType, node *kapi.Node) error

func (*StatusAdmitter) HandleRoute added in v1.1.3

func (a *StatusAdmitter) HandleRoute(eventType watch.EventType, route *routeapi.Route) error

HandleRoute attempts to admit the provided route on watch add / modifications.

func (*StatusAdmitter) RecordRouteRejection added in v1.1.3

func (a *StatusAdmitter) RecordRouteRejection(route *routeapi.Route, reason, message string)

RecordRouteRejection attempts to update the route status with a reason for a route being rejected.

type UniqueHost added in v1.0.6

type UniqueHost struct {
	// contains filtered or unexported fields
}

UniqueHost implements the router.Plugin interface to provide a template based, backend-agnostic router.

func NewUniqueHost added in v1.0.6

func NewUniqueHost(plugin router.Plugin, fn RouteHostFunc, disableOwnershipCheck bool, recorder RejectionRecorder) *UniqueHost

NewUniqueHost creates a plugin wrapper that ensures only unique routes are passed into the underlying plugin. Recorder is an interface for indicating why a route was rejected.

func (*UniqueHost) Commit added in v1.5.0

func (p *UniqueHost) Commit() error

func (*UniqueHost) HandleEndpoints added in v1.0.6

func (p *UniqueHost) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error

HandleEndpoints processes watch events on the Endpoints resource.

func (*UniqueHost) HandleNamespaces added in v1.0.6

func (p *UniqueHost) HandleNamespaces(namespaces sets.String) error

HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.

func (*UniqueHost) HandleNode added in v1.4.0

func (p *UniqueHost) HandleNode(eventType watch.EventType, node *kapi.Node) error

HandleNode processes watch events on the Node resource and calls the router

func (*UniqueHost) HandleRoute added in v1.0.6

func (p *UniqueHost) HandleRoute(eventType watch.EventType, route *routeapi.Route) error

HandleRoute processes watch events on the Route resource. TODO: this function can probably be collapsed with the router itself, as a function that

determines which component needs to be recalculated (which template) and then does so
on demand.

func (*UniqueHost) HostLen added in v1.0.6

func (p *UniqueHost) HostLen() int

HostLen returns the number of hosts currently tracked by this plugin.

func (*UniqueHost) RoutesForHost added in v1.0.6

func (p *UniqueHost) RoutesForHost(host string) ([]*routeapi.Route, bool)

RoutesForHost is a helper that allows routes to be retrieved.

Directories

Path Synopsis
Package factory contains code used to create the router controller.
Package factory contains code used to create the router controller.

Jump to

Keyboard shortcuts

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