Documentation ¶
Index ¶
- Constants
- func NewFakeTemplateRouter() *templateRouter
- func SanitizeHeaderValue(headerValue string) string
- type CaptureHTTPCookie
- type CaptureHTTPHeader
- type Certificate
- type ConfigManager
- type ConfigManagerOptions
- type CookieMatchType
- type Endpoint
- type HTTPHeader
- type HTTPHeaderNameCaseAdjustment
- type RouterEventType
- type RouterInterface
- type ServiceAliasConfig
- type ServiceAliasConfigKey
- type ServiceAliasConfigStatus
- type ServiceLookup
- type ServiceUnit
- type ServiceUnitKey
- type TemplatePlugin
- func (p *TemplatePlugin) Commit() error
- func (p *TemplatePlugin) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error
- func (p *TemplatePlugin) HandleNamespaces(namespaces sets.String) error
- func (p *TemplatePlugin) HandleNode(eventType watch.EventType, node *kapi.Node) error
- func (p *TemplatePlugin) HandleRoute(eventType watch.EventType, route *routev1.Route) error
- func (p *TemplatePlugin) Stop() error
- type TemplatePluginConfig
Constants ¶
const ( ProtocolHTTP = "http" ProtocolHTTPS = "https" ProtocolTLS = "tls" )
const ( // RouterEventReloadStart indicates start of a template router reload. RouterEventReloadStart = "reload-start" // RouterEventReloadEnd indicates end of a template router reload. RouterEventReloadEnd = "reload-end" // RouterEventReloadError indicates error on a template router reload. RouterEventReloadError = "reload-error" )
Variables ¶
This section is empty.
Functions ¶
func NewFakeTemplateRouter ¶
func NewFakeTemplateRouter() *templateRouter
NewFakeTemplateRouter provides an empty template router with a simple certificate manager backed by a fake cert writer for testing
func SanitizeHeaderValue ¶
Types ¶
type CaptureHTTPCookie ¶
type CaptureHTTPCookie struct { // Name specifies an HTTP cookie name. Name string // MaxLength specifies a maximum length for the cookie value. MaxLength int // MatchType specifies the type of match to be performed on the cookie // name. MatchType CookieMatchType }
CaptureHTTPCookie specifies an HTTP cookie that should be captured for access logs.
type CaptureHTTPHeader ¶
type CaptureHTTPHeader struct { // Name specifies an HTTP header name. Name string // MaxLength specifies a maximum length for the header value. MaxLength int }
CaptureHTTPHeader specifies an HTTP header that should be captured for access logs.
type Certificate ¶
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 ConfigManager ¶
type ConfigManager interface { // Initialize initializes the config manager. Initialize(router RouterInterface, certPath string) // AddBlueprint adds a new (or replaces an existing) route blueprint. AddBlueprint(route *routev1.Route) error // RemoveBlueprint removes a route blueprint. RemoveBlueprint(route *routev1.Route) // Register registers an id to be associated with a route. Register(id ServiceAliasConfigKey, route *routev1.Route) // AddRoute adds a new route or updates an existing route. AddRoute(id ServiceAliasConfigKey, routingKey string, route *routev1.Route) error // RemoveRoute removes a route. RemoveRoute(id ServiceAliasConfigKey, route *routev1.Route) error // ReplaceRouteEndpoints replaces a subset (the ones associated with // a single service unit) of a route endpoints. ReplaceRouteEndpoints(id ServiceAliasConfigKey, oldEndpoints, newEndpoints []Endpoint, weight int32) error // RemoveRouteEndpoints removes a set of endpoints from a route. RemoveRouteEndpoints(id ServiceAliasConfigKey, endpoints []Endpoint) error // Notify notifies a configuration manager of a router event. // Currently the only ones that are received are on reload* events, // which indicates whether or not the configuration manager should // reset all the dynamically applied changes it is keeping track of. Notify(event RouterEventType) // ServerTemplateName returns the dynamic server template name. ServerTemplateName(id ServiceAliasConfigKey) string // ServerTemplateSize returns the dynamic server template size. ServerTemplateSize(id ServiceAliasConfigKey) string // GenerateDynamicServerNames generates the dynamic server names. GenerateDynamicServerNames(id ServiceAliasConfigKey) []string }
ConfigManager is used by the router to make configuration changes using the template router's dynamic configuration API (if any). Please note that the code calling the ConfigManager interface methods needs to ensure that a lock is acquired and released in order to guarantee Config Manager consistency. The haproxy specific implementation of the ConfigManager itself does guarantee consistency with internal locks but it is not a hard requirement for a ConfigManager "provider".
type ConfigManagerOptions ¶
type ConfigManagerOptions struct { // ConnectionInfo specifies how to connect to the underlying router. ConnectionInfo string // CommitInterval specifies how often to commit changes made to the // underlying router via the configuration manager. CommitInterval time.Duration // BlueprintRoutes are a list of routes blueprints pre-allocated by // the config manager to dynamically manage route additions. BlueprintRoutes []*routev1.Route // BlueprintRoutePoolSize is the size of the pre-allocated pool for // each route blueprint. This can be overriden on an individual // route basis with a route annotation: // router.openshift.io/pool-size BlueprintRoutePoolSize int // MaxDynamicServers is the maximum number of dynamic servers we // will allocate on a per-route basis. MaxDynamicServers int // WildcardRoutesAllowed indicates if wildcard routes are allowed. WildcardRoutesAllowed bool // ExtendedValidation indicates if extended route validation is enabled. ExtendedValidation bool }
ConfigManagerOptions is the options passed to a template router's configuration manager.
type CookieMatchType ¶
type CookieMatchType string
CookieMatchType indicates the type of matching used against cookie names to select a cookie for capture.
const ( // CookieMatchTypeExact indicates that an exact match should be performed. CookieMatchTypeExact CookieMatchType = "exact" // CookieMatchTypePrefix indicates that a prefix match should be performed. CookieMatchTypePrefix CookieMatchType = "prefix" )
type Endpoint ¶
type Endpoint struct { ID string IP string Port string TargetName string PortName string IdHash string NoHealthCheck bool AppProtocol string }
Endpoint is an internal representation of a k8s endpoint.
type HTTPHeader ¶
type HTTPHeader struct { // Name specifies an HTTP header name. Name string // Value specifies the header value. Value string // Action specifies the action to be performed. Action routev1.RouteHTTPHeaderActionType }
HTTPHeader specifies an HTTP header that should be set or deleted.
type HTTPHeaderNameCaseAdjustment ¶
type HTTPHeaderNameCaseAdjustment struct { // From specifies the original header name. It must be a valid HTTP // header name in lower case. From string // To specifies the desired header name. It should be the same as From // but with the desired capitalization. To string }
HTTPHeaderNameCaseAdjustment specifies an HTTP header that should have its capitalization adjusted, and how the header should be adjusted.
type RouterEventType ¶
type RouterEventType string
RouterEventType indicates the type of event fired by the router.
type RouterInterface ¶
type RouterInterface interface { // SyncedAtLeastOnce indicates an initial sync has been performed SyncedAtLeastOnce() bool // CreateServiceUnit creates a new service named with the given id. CreateServiceUnit(id ServiceUnitKey) // FindServiceUnit finds the service with the given id. FindServiceUnit(id ServiceUnitKey) (v ServiceUnit, ok bool) // AddEndpoints adds new Endpoints for the given id. AddEndpoints(id ServiceUnitKey, endpoints []Endpoint) // DeleteEndpoints deletes the endpoints for the frontend with the given id. DeleteEndpoints(id ServiceUnitKey) // AddRoute attempts to add a route to the router. AddRoute(route *routev1.Route) // RemoveRoute removes the given route RemoveRoute(route *routev1.Route) // HasRoute indicates whether the router is configured with the given route HasRoute(route *routev1.Route) bool // Reduce the list of routes to only these namespaces FilterNamespaces(namespaces sets.String) // Commit applies the changes in the background. It kicks off a rate-limited // commit (persist router state + refresh the backend) that coalesces multiple changes. Commit() }
RouterInterface controls the interaction of the plugin with the underlying router implementation
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 routev1.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 routev1.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 // ServiceUnits is the weight for each service assigned to the route. // It is used in calculating the weight for the server that is found in ServiceUnitNames ServiceUnits map[ServiceUnitKey]int32 // ServiceUnitNames is the weight to apply to each endpoint of each service supporting this route. // The value is the scaled portion of the service weight to assign // to each endpoint in the service. ServiceUnitNames map[ServiceUnitKey]int32 // ActiveServiceUnits is a count of the service units with a non-zero weight ActiveServiceUnits int // ActiveEndpoints is a count of the route endpoints that are part of a service unit with a non-zero weight ActiveEndpoints int // HTTPResponseHeaders has route-specific custom HTTP response headers. HTTPResponseHeaders []HTTPHeader // HTTPResponseHeaders has route-specific custom HTTP request headers. HTTPRequestHeaders []HTTPHeader }
ServiceAliasConfig is a route for a service. Uniquely identified by host + path.
type ServiceAliasConfigKey ¶
type ServiceAliasConfigKey string
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 ¶
ServiceLookup is an interface for fetching the service associated with the given endpoints
func NewListWatchServiceLookup ¶
func NewListWatchServiceLookup(svcGetter kcoreclient.ServicesGetter, resync time.Duration, namespace string) 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 // ServiceAliasAssociations indicates what service aliases are // associated with this service unit. ServiceAliasAssociations map[ServiceAliasConfigKey]bool }
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 ServiceUnitKey ¶
type ServiceUnitKey string
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 ¶
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 ¶
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 ¶
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 (*TemplatePlugin) Stop ¶
func (p *TemplatePlugin) Stop() error
Stop instructs the router plugin to stop invoking the reload method, and waits until no further reloads will occur. It then invokes the reload script one final time with the ROUTER_SHUTDOWN environment variable set with true.
type TemplatePluginConfig ¶
type TemplatePluginConfig struct { WorkingDir string TemplatePath string ReloadScriptPath string ReloadFn func(shutdown bool) error ReloadInterval time.Duration ReloadCallbacks []func() DefaultCertificate string DefaultCertificatePath string DefaultCertificateDir string DefaultDestinationCAPath string StatsPort int StatsUsername string StatsPassword string IncludeUDP bool AllowWildcardRoutes bool BindPortsAfterSync bool MaxConnections string Ciphers string StrictSNI bool DynamicConfigManager ConfigManager CaptureHTTPRequestHeaders []CaptureHTTPHeader CaptureHTTPResponseHeaders []CaptureHTTPHeader CaptureHTTPCookie *CaptureHTTPCookie HTTPHeaderNameCaseAdjustments []HTTPHeaderNameCaseAdjustment HTTPResponseHeaders []HTTPHeader HTTPRequestHeaders []HTTPHeader }