gateway

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile_HTTPHeaderMatch

func Compile_HTTPHeaderMatch(headerMatch *gw.HTTPHeaderMatch) ([]*v3route.HeaderMatcher, error)

func Compile_HTTPRouteForwardTo

func Compile_HTTPRouteForwardTo(src Source, forward gw.HTTPRouteForwardTo, namespace string, clusterRefs *[]*ClusterRef) *v3route.WeightedCluster_ClusterWeight

func Compile_HTTPRouteMatch

func Compile_HTTPRouteMatch(match gw.HTTPRouteMatch) (*v3route.RouteMatch, error)

func Compile_HTTPRouteMatches

func Compile_HTTPRouteMatches(matches []gw.HTTPRouteMatch) ([]*v3route.RouteMatch, error)

func Compile_HTTPRouteRule

func Compile_HTTPRouteRule(src Source, rule gw.HTTPRouteRule, namespace string, clusterRefs *[]*ClusterRef) ([]*v3route.Route, error)

Types

type ClusterRef

type ClusterRef struct {
	CompiledItem
	Name string

	// These are temporary fields to deal with how endpoints are currently plumbed from the watcher
	// through to ambex.
	EndpointPath string
}

ClusterRef represents a reference to an envoy v2.Cluster.

type CompiledCluster

type CompiledCluster struct {
	CompiledItem
	Cluster *v3cluster.Cluster
}

CompiledCluster decorates an envoy v2.Cluster.

type CompiledConfig

type CompiledConfig struct {
	CompiledItem
	Listeners       []*CompiledListener
	Routes          []*CompiledRoute
	Clusters        []*CompiledCluster
	LoadAssignments []*CompiledLoadAssignment
}

CompiledConfig can hold any amount of any kind of envoy configuration fragments. All compile functions produce this type.

func Compile_Endpoints

func Compile_Endpoints(endpoints *kates.Endpoints) (*CompiledConfig, error)

Compile_Endpoints transforms a kubernetes endpoints resource into a v3endpoint.ClusterLoadAssignment

func Compile_Gateway

func Compile_Gateway(gateway *gw.Gateway) (*CompiledConfig, error)

func Compile_HTTPRoute

func Compile_HTTPRoute(httpRoute *gw.HTTPRoute) (*CompiledConfig, error)

type CompiledItem

type CompiledItem struct {
	Source    Source // Tracks the source of truth for whatever produced this compiled item.
	Namespace string // The namespace of whatever produced this item.
	Error     string // Holds any error associated with this compiled item.
}

CompiledItem has fields common to all compilation units.

func NewCompiledItem

func NewCompiledItem(source Source) CompiledItem

func NewCompiledItemError

func NewCompiledItemError(source Source, error string) CompiledItem

type CompiledListener

type CompiledListener struct {
	CompiledItem
	Listener *v3listener.Listener

	// The predicate determines which routes belong to which listeners. If the listener specifies
	// and Rds configuration, this Predicate and the Domains below will be used to construct a
	// RouteConfiguration from all the available CompiledRoutes.
	Predicate func(route *CompiledRoute) bool
	Domains   []string
}

CompiledListener is an envoy Listener plus a Predicate that the dispatcher uses to determine which routes to supply to the listener.

func Compile_Listener

func Compile_Listener(parent Source, lst gw.Listener, name string) (*CompiledListener, error)

type CompiledLoadAssignment

type CompiledLoadAssignment struct {
	CompiledItem
	LoadAssignment *v3endpoint.ClusterLoadAssignment
}

CompiledLoadAssignment decorates an envoy v2.ClusterLoadAssignment.

type CompiledRoute

type CompiledRoute struct {
	CompiledItem

	// This field will likely get replaced with something more astract, e.g. just info about the
	// source such as labels kind, namespace, name, etc.
	HTTPRoute *gw.HTTPRoute

	Routes      []*v3route.Route
	ClusterRefs []*ClusterRef
}

CompiledRoute is

type Dispatcher

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

The Dispatcher struct allows transforms to be registered for different kinds of kubernetes resources and invokes those transforms to produce compiled envoy configurations. It also knows how to assemble the compiled envoy configuration into a complete snapshot.

Currently the dispatch process is relatively simple, each resource is processed as an independent unit. This is sufficient for the gateway API since the currently implemented resources are conveniently defined in such a way as to make them independent.

Consistency is guaranteed assuming transform functions don't use out of band communication to include information from other resources. This guarantee is achieved because each transform is only passed a single resource and can therefore only use information from that one resource. Changes to any other resource cannot impact the result of that transform.

Not all the edgestack resources are defined as conveniently, so the Dispatcher design is expected to be extended in two ways to handle resources with more complex interdependencies:

  1. Grouping -- This feature would cover resources that need to be processed as a group, e.g. Mappings that get grouped together based on prefix. Instead of dispatching at the granularity of a single resource, the dispatcher will track groups of resources that need to be processed together via a logical "hash" function provided at registration. Whenever any item in a given bucket changes, the dispatcher will transform the entire bucket.

  2. Dependencies -- This feature would cover resources that need to lookup the contents of other resources in order to properly implement their transform. This would be done by passing the transform function a Query API. Any resources queried by the transform would be automatically tracked as a dependency of that resource. The dependencies would then be used to perform invalidation whenever a resource is Upsert()ed.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a new and empty *Dispatcher struct.

func (*Dispatcher) Delete

func (d *Dispatcher) Delete(resource kates.Object)

Delete processes the deletion of the given kubernetes resource.

func (*Dispatcher) DeleteKey

func (d *Dispatcher) DeleteKey(kind, namespace, name string)

func (*Dispatcher) GetErrors

func (d *Dispatcher) GetErrors() []*CompiledItem

GetErrors returns all compiled items with errors.

func (*Dispatcher) GetListener

func (d *Dispatcher) GetListener(ctx context.Context, name string) *v3listener.Listener

GetListener returns a *v3listener.Listener with the specified name or nil if none exists.

func (*Dispatcher) GetRouteConfiguration

func (d *Dispatcher) GetRouteConfiguration(ctx context.Context, name string) *v3route.RouteConfiguration

GetRouteConfiguration returns a *apiv2.RouteConfiguration with the specified name or nil if none exists.

func (*Dispatcher) GetSnapshot

func (d *Dispatcher) GetSnapshot(ctx context.Context) (string, *ecp_v3_cache.Snapshot)

GetSnapshot returns a version and a snapshot if the snapshot is consistent Important: a nil snapshot can be returned so you must check to to make sure it exists

func (*Dispatcher) IsRegistered

func (d *Dispatcher) IsRegistered(kind string) bool

IsRegistered returns true if the given kind can be processed by this dispatcher.

func (*Dispatcher) IsWatched

func (d *Dispatcher) IsWatched(namespace, name string) bool

IsWatched is a temporary hack for dealing with the way endpoint data currenttly flows from watcher -> ambex.n

func (*Dispatcher) Register

func (d *Dispatcher) Register(kind string, transform func(kates.Object) (*CompiledConfig, error)) error

Register registers a transform function for the specified kubernetes resource. The transform argument must be a function that takes a single resource of the supplied "kind" and returns a single CompiledConfig object, i.e.: `func(Kind) *CompiledConfig`

func (*Dispatcher) Upsert

func (d *Dispatcher) Upsert(resource kates.Object) error

Upsert processes the given kubernetes resource whether it is new or just updated.

func (*Dispatcher) UpsertYaml

func (d *Dispatcher) UpsertYaml(manifests string) error

UpsertYaml parses the supplied yaml and invokes Upsert on the result.

type ResourceRef

type ResourceRef struct {
	Kind      string
	Namespace string
	Name      string
}

type Source

type Source interface {
	Location() string
}

func SourceFromResource

func SourceFromResource(resource kates.Object) Source

func Sourcef

func Sourcef(pattern string, args ...interface{}) Source

Jump to

Keyboard shortcuts

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