Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyDirectResponse(out *route.Route, directResponse *networking.HTTPDirectResponse)
- func ApplyRedirect(out *route.Route, redirect *networking.HTTPRedirect, port int, isTLS bool, ...)
- func BuildDefaultHTTPInboundRoute(proxy *model.Proxy, clusterName string, operation string) *route.Route
- func BuildDefaultHTTPOutboundRoute(clusterName string, operation string, mesh *meshconfig.MeshConfig) *route.Route
- func BuildHTTPRoutesForVirtualService(node *model.Proxy, virtualService config.Config, ...) ([]*route.Route, error)
- func GetDestinationCluster(destination *networking.Destination, service *model.Service, listenerPort int) string
- func GetRouteOperation(in *route.Route, vsName string, port int) string
- func IsCatchAllRoute(r *route.Route) bool
- func MirrorPercent(in *networking.HTTPRoute) *core.RuntimeFractionalPercent
- func MirrorPercentByPolicy(mirror *networking.HTTPMirrorPolicy) *core.RuntimeFractionalPercent
- func SortVHostRoutes(routes []*route.Route) []*route.Route
- func TranslateCORSPolicy(proxy *model.Proxy, in *networking.CorsPolicy) *cors.CorsPolicy
- func TranslateFault(in *networking.HTTPFaultInjection) *xdshttpfault.HTTPFault
- func TranslateRequestMirrorPolicy(dst *networking.Destination, service *model.Service, listenerPort int, ...) *route.RouteAction_RequestMirrorPolicy
- func TranslateRequestMirrorPolicyCluster(cluster string, mp *core.RuntimeFractionalPercent) *route.RouteAction_RequestMirrorPolicy
- func TranslateRouteMatch(vs config.Config, in *networking.HTTPMatchRequest) *route.RouteMatch
- type Cache
- type DestinationHashMap
- type HeadersOperations
- type RouteOptions
- type SortHeaderValueOption
- type VirtualHostWrapper
Constants ¶
const ( HeaderMethod = ":method" HeaderAuthority = ":authority" HeaderScheme = ":scheme" )
Headers with special meaning in Envoy
const DefaultRouteName = "default"
DefaultRouteName is the name assigned to a route generated by default in absence of a virtual service.
Variables ¶
var ( Separator = []byte{'~'} Slash = []byte{'/'} )
var DefaultMaxDirectResponseBodySizeBytes = wrapperspb.UInt32(1024 * 1024)
DefaultMaxDirectResponseBodySizeBytes is 1mb, the same limit the control plane validates via webhook. Set this to increase from envoy default of 4k
var Notimeout = durationpb.New(0)
Functions ¶
func ApplyDirectResponse ¶
func ApplyDirectResponse(out *route.Route, directResponse *networking.HTTPDirectResponse)
func ApplyRedirect ¶
func ApplyRedirect(out *route.Route, redirect *networking.HTTPRedirect, port int, isTLS bool, useGatewaySemantics bool)
func BuildDefaultHTTPInboundRoute ¶
func BuildDefaultHTTPInboundRoute(proxy *model.Proxy, clusterName string, operation string) *route.Route
BuildDefaultHTTPInboundRoute builds a default inbound route.
func BuildDefaultHTTPOutboundRoute ¶
func BuildDefaultHTTPOutboundRoute(clusterName string, operation string, mesh *meshconfig.MeshConfig) *route.Route
BuildDefaultHTTPOutboundRoute builds a default outbound route, including a retry policy.
func BuildHTTPRoutesForVirtualService ¶
func BuildHTTPRoutesForVirtualService( node *model.Proxy, virtualService config.Config, serviceRegistry map[host.Name]*model.Service, hashByDestination DestinationHashMap, listenPort int, gatewayNames sets.String, opts RouteOptions, ) ([]*route.Route, error)
BuildHTTPRoutesForVirtualService creates data plane HTTP routes from the virtual service spec. The rule should be adapted to destination names (outbound clusters). Each rule is guarded by source labels.
This is called for each port to compute virtual hosts. Each VirtualService is tried, with a list of Services that listen on the port. Error indicates the given virtualService can't be used on the port. This function is used by both the gateway and the sidecar
func GetDestinationCluster ¶
func GetDestinationCluster(destination *networking.Destination, service *model.Service, listenerPort int) string
GetDestinationCluster generates a cluster name for the route. If the destination is invalid or cannot be found, "UnknownService" is returned.
func GetRouteOperation ¶
GetRouteOperation returns readable route description for trace.
func IsCatchAllRoute ¶
IsCatchAllRoute returns true if an Envoy route is a catchall route otherwise false.
func MirrorPercent ¶
func MirrorPercent(in *networking.HTTPRoute) *core.RuntimeFractionalPercent
MirrorPercent computes the mirror percent to be used based on "Mirror" data in route.
func MirrorPercentByPolicy ¶
func MirrorPercentByPolicy(mirror *networking.HTTPMirrorPolicy) *core.RuntimeFractionalPercent
MirrorPercentByPolicy computes the mirror percent to be used based on HTTPMirrorPolicy.
func SortVHostRoutes ¶
SortVHostRoutes moves the catch all routes alone to the end, while retaining the relative order of other routes in the slice.
func TranslateCORSPolicy ¶
func TranslateCORSPolicy(proxy *model.Proxy, in *networking.CorsPolicy) *cors.CorsPolicy
TranslateCORSPolicy translates CORS policy
func TranslateFault ¶
func TranslateFault(in *networking.HTTPFaultInjection) *xdshttpfault.HTTPFault
TranslateFault translates networking.HTTPFaultInjection into Envoy's HTTPFault
func TranslateRequestMirrorPolicy ¶
func TranslateRequestMirrorPolicy(dst *networking.Destination, service *model.Service, listenerPort int, mp *core.RuntimeFractionalPercent, ) *route.RouteAction_RequestMirrorPolicy
func TranslateRequestMirrorPolicyCluster ¶
func TranslateRequestMirrorPolicyCluster(cluster string, mp *core.RuntimeFractionalPercent, ) *route.RouteAction_RequestMirrorPolicy
func TranslateRouteMatch ¶
func TranslateRouteMatch(vs config.Config, in *networking.HTTPMatchRequest) *route.RouteMatch
TranslateRouteMatch translates match condition
Types ¶
type Cache ¶
type Cache struct { RouteName string ProxyVersion string // proxy cluster ID ClusterID string // proxy dns domain DNSDomain string // DNSCapture indicates whether the workload has enabled dns capture DNSCapture bool // DNSAutoAllocate indicates whether the workload should have auto allocated addresses for ServiceEntry // This allows resolving ServiceEntries, which is especially useful for distinguishing TCP traffic // This depends on DNSCapture. DNSAutoAllocate bool // AllowAny indicates if the proxy should allow all outbound traffic or only known registries AllowAny bool ListenerPort int Services []*model.Service VirtualServices []config.Config DelegateVirtualServices []model.ConfigHash DestinationRules []*model.ConsolidatedDestRule EnvoyFilterKeys []string }
Cache includes the variables that can influence a Route Configuration. Implements XdsCacheEntry interface.
func (*Cache) DependentConfigs ¶
func (r *Cache) DependentConfigs() []model.ConfigHash
type DestinationHashMap ¶
type DestinationHashMap map[*networking.HTTPRouteDestination]*networking.LoadBalancerSettings_ConsistentHashLB
func GetConsistentHashForVirtualService ¶
func GetConsistentHashForVirtualService(push *model.PushContext, node *model.Proxy, virtualService config.Config) DestinationHashMap
type HeadersOperations ¶
type HeadersOperations struct { RequestHeadersToAdd []*core.HeaderValueOption ResponseHeadersToAdd []*core.HeaderValueOption RequestHeadersToRemove []string ResponseHeadersToRemove []string Authority string }
func TranslateHeadersOperations ¶
func TranslateHeadersOperations(headers *networking.Headers) HeadersOperations
TranslateHeadersOperations translates headers operations
type RouteOptions ¶
type RouteOptions struct { // IsTLS indicates if the route is intended for a TLS listener IsTLS bool // IsHTTP3AltSvcHeaderNeeded indicates if HTTP3 alt-svc header needs to be inserted IsHTTP3AltSvcHeaderNeeded bool Mesh *meshconfig.MeshConfig }
type SortHeaderValueOption ¶
type SortHeaderValueOption []*core.HeaderValueOption
SortHeaderValueOption type and the functions below (Len, Less and Swap) are for sort.Stable for type HeaderValueOption
func (SortHeaderValueOption) Len ¶
func (b SortHeaderValueOption) Len() int
Len is i the sort.Interface for SortHeaderValueOption
func (SortHeaderValueOption) Less ¶
func (b SortHeaderValueOption) Less(i, j int) bool
Less is in the sort.Interface for SortHeaderValueOption
func (SortHeaderValueOption) Swap ¶
func (b SortHeaderValueOption) Swap(i, j int)
Swap is in the sort.Interface for SortHeaderValueOption
type VirtualHostWrapper ¶
type VirtualHostWrapper struct { // Port is the listener port for outbound sidecar (e.g. service port) Port int // Services are the Services from the registry. Each service // in this list should have a virtual host entry Services []*model.Service // VirtualServiceHosts is a list of hosts defined in the virtual service // if virtual service hostname is same as a the service registry host, then // the host would appear in Services as we need to generate all variants of the // service's hostname within a platform (e.g., foo, foo.default, foo.default.svc, etc.) VirtualServiceHosts []string // Routes in the virtual host Routes []*route.Route }
VirtualHostWrapper is a context-dependent virtual host entry with guarded routes. Note: Currently we are not fully utilizing this structure. We could invoke this logic once for all sidecars in the cluster to compute all RDS for inside the mesh and arrange it by listener port. However to properly use such an optimization, we need to have an eventing subsystem to invalidate the computed routes if any service changes/virtual Services change.
func BuildSidecarVirtualHostWrapper ¶
func BuildSidecarVirtualHostWrapper(routeCache *Cache, node *model.Proxy, push *model.PushContext, serviceRegistry map[host.Name]*model.Service, virtualServices []config.Config, listenPort int, mostSpecificWildcardVsIndex map[host.Name]types.NamespacedName, ) []VirtualHostWrapper
BuildSidecarVirtualHostWrapper creates virtual hosts from the given set of virtual Services and a list of Services from the service registry. Services are indexed by FQDN hostnames. The list of Services is also passed to allow maintaining consistent ordering.