Documentation ¶
Index ¶
- Constants
- func NewFakeTemplateRouter() *templateRouter
- type Certificate
- type ConfigManager
- type ConfigManagerOptions
- type Endpoint
- type RouterEventType
- type RouterInterface
- type ServiceAliasConfig
- type ServiceAliasConfigStatus
- type ServiceLookup
- type ServiceUnit
- 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
- 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 ¶ 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 ¶
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) // RemoveBlueprint removes a route blueprint. RemoveBlueprint(route *routev1.Route) // Register registers an id to be associated with a route. Register(id string, route *routev1.Route) // AddRoute adds a new route or updates an existing route. AddRoute(id, routingKey string, route *routev1.Route) error // RemoveRoute removes a route. RemoveRoute(id string, route *routev1.Route) error // ReplaceRouteEndpoints replaces a subset (the ones associated with // a single service unit) of a route endpoints. ReplaceRouteEndpoints(id string, oldEndpoints, newEndpoints []Endpoint, weight int32) error // RemoveRouteEndpoints removes a set of endpoints from a route. RemoveRouteEndpoints(id string, 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 string) string // ServerTemplateSize returns the dynamic server template size. ServerTemplateSize(id string) string // GenerateDynamicServerNames generates the dynamic server names. GenerateDynamicServerNames(id string) []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 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 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 string) // FindServiceUnit finds the service with the given id. FindServiceUnit(id string) (v ServiceUnit, ok bool) // AddEndpoints adds new Endpoints for the given id. AddEndpoints(id string, endpoints []Endpoint) // DeleteEndpoints deletes the endpoints for the frontend with the given id. DeleteEndpoints(id string) // 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 keyed by service name. // It is used in calculating the weight for the server that is found in ServiceUnitNames ServiceUnits map[string]int32 // ServiceUnitNames is the weight to apply to each endpoint of each service supporting this route. // The key is the service name, the value is the scaled portion of the service weight to assign // to each endpoint in the service. ServiceUnitNames map[string]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 }
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
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, 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[string]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 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.1
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
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.
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 DynamicConfigManager ConfigManager }