templaterouter

package
v3.6.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2017 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolHTTP  = "http"
	ProtocolHTTPS = "https"
	ProtocolTLS   = "tls"
)

Variables

This section is empty.

Functions

func NewFakeTemplateRouter added in v1.3.0

func NewFakeTemplateRouter() *templateRouter

NewFakeTemplateRouter provides an empty template router with a simple certificate manager backed by a fake cert writer for testing

Types

type Certificate

type Certificate struct {
	ID         string
	Contents   string
	PrivateKey string
}

Certificate represents a pub/private key pair. It is identified by ID which will become the file name. A CA certificate will not have a PrivateKey set.

type Endpoint

type Endpoint struct {
	ID            string
	IP            string
	Port          string
	TargetName    string
	PortName      string
	IdHash        string
	NoHealthCheck bool
}

Endpoint is an internal representation of a k8s endpoint.

type ServiceAliasConfig

type ServiceAliasConfig struct {
	// Name is the user-specified name of the route.
	Name string
	// Namespace is the namespace of the route.
	Namespace string
	// Host is a required host name ie. www.example.com
	Host string
	// Path is an optional path ie. www.example.com/myservice where "myservice" is the path
	Path string
	// TLSTermination is the termination policy for this backend and drives the mapping files and router configuration
	TLSTermination routeapi.TLSTerminationType
	// Certificates used for securing this backend.  Keyed by the cert id
	Certificates map[string]Certificate
	// VerifyServiceHostname is true if the backend service(s) are expected to have serving certificates that sign for
	// the name "service.namespace.svc".
	VerifyServiceHostname bool
	// Indicates the status of configuration that needs to be persisted.  Right now this only
	// includes the certificates and is not an indicator of being written to the underlying
	// router implementation
	Status ServiceAliasConfigStatus
	// Indicates the port the user wishes to expose. If empty, a port will be selected for the service.
	PreferPort string
	// InsecureEdgeTerminationPolicy indicates desired behavior for
	// insecure connections to an edge-terminated route:
	//   none (or disable), allow or redirect
	InsecureEdgeTerminationPolicy routeapi.InsecureEdgeTerminationPolicyType

	// Hash of the route name - used to obscure cookieId
	RoutingKeyName string

	// IsWildcard indicates this service unit needs wildcarding support.
	IsWildcard bool

	// Annotations attached to this route
	Annotations map[string]string

	// ServiceUnitNames is a collection of services that support this route, keyed by service name
	// and valued on the weight attached to it with respect to other entries in the map
	ServiceUnitNames map[string]int32

	// ActiveServiceUnits is a count of the service units with a non-zero weight
	ActiveServiceUnits int
}

ServiceAliasConfig is a route for a service. Uniquely identified by host + path.

type ServiceAliasConfigStatus

type ServiceAliasConfigStatus string
const (
	// ServiceAliasConfigStatusSaved indicates that the necessary files for this config have
	// been persisted to disk.
	ServiceAliasConfigStatusSaved ServiceAliasConfigStatus = "saved"
)

type ServiceLookup added in v1.3.0

type ServiceLookup interface {
	LookupService(*api.Endpoints) (*api.Service, error)
}

ServiceLookup is an interface for fetching the service associated with the given endpoints

func NewListWatchServiceLookup added in v1.3.0

func NewListWatchServiceLookup(svcGetter kcoreclient.ServicesGetter, resync time.Duration) ServiceLookup

type ServiceUnit

type ServiceUnit struct {
	// Name corresponds to a service name & namespace.  Uniquely identifies the ServiceUnit
	Name string
	// Hostname is the name of this service.
	Hostname string
	// EndpointTable are endpoints that back the service, this translates into a final backend
	// implementation for routers.
	EndpointTable []Endpoint
}

ServiceUnit represents a service and its endpoints.

func (ServiceUnit) TemplateSafeName

func (s ServiceUnit) TemplateSafeName() string

TemplateSafeName provides a name that can be used in the template that does not contain restricted characters like / which is used to concat namespace and name in the service unit key

type TemplatePlugin

type TemplatePlugin struct {
	Router         routerInterface
	IncludeUDP     bool
	ServiceFetcher ServiceLookup
}

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

func NewTemplatePlugin

func NewTemplatePlugin(cfg TemplatePluginConfig, lookupSvc ServiceLookup) (*TemplatePlugin, error)

NewTemplatePlugin creates a new TemplatePlugin.

func (*TemplatePlugin) Commit added in v1.5.0

func (p *TemplatePlugin) Commit() error

func (*TemplatePlugin) HandleEndpoints

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

HandleEndpoints processes watch events on the Endpoints resource.

func (*TemplatePlugin) HandleNamespaces

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

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

func (*TemplatePlugin) HandleNode added in v1.4.0

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

HandleNode processes watch events on the Node resource The template type of plugin currently does not need to act on such events so the implementation just returns without error

func (*TemplatePlugin) HandleRoute

func (p *TemplatePlugin) 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.

type TemplatePluginConfig

type TemplatePluginConfig struct {
	WorkingDir               string
	TemplatePath             string
	ReloadScriptPath         string
	ReloadInterval           time.Duration
	ReloadCallbacks          []func()
	DefaultCertificate       string
	DefaultCertificatePath   string
	DefaultCertificateDir    string
	DefaultDestinationCAPath string
	StatsPort                int
	StatsUsername            string
	StatsPassword            string
	IncludeUDP               bool
	AllowWildcardRoutes      bool
	PeerService              *ktypes.NamespacedName
	BindPortsAfterSync       bool
	MaxConnections           string
	Ciphers                  string
	StrictSNI                bool
}

Jump to

Keyboard shortcuts

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