Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalAny(message proto.Message) *anypb.Any
- func UnmarshalCDS(rawResources []*anypb.Any) (map[string]Resource, error)
- func UnmarshalEDS(rawResources []*anypb.Any) (map[string]Resource, error)
- func UnmarshalLDS(rawResources []*anypb.Any) (map[string]*ListenerResource, error)
- func UnmarshalRDS(rawResources []*anypb.Any) (map[string]Resource, error)
- type ClusterDiscoveryType
- type ClusterLbPolicy
- type ClusterResource
- type Endpoint
- type EndpointsResource
- type ExactMatcher
- type HTTPRouteConfig
- type HTTPRouteMatch
- type ListenerResource
- type Locality
- type Matcher
- type Matchers
- type NDSResource
- type NetworkFilter
- type NetworkFilterType
- type OutlierDetection
- type PrefixMatcher
- type RegexMatcher
- type Resource
- type ResourceMeta
- type ResourceType
- type RetryBackOff
- type RetryPolicy
- type Route
- type RouteConfigResource
- type RouteMatch
- type ThriftRouteConfig
- type ThriftRouteMatch
- type VirtualHost
- type WeightedCluster
- type XDSUpdateHandler
Constants ¶
const ( // ReservedLdsResourceName the virtualInbound is used for server side configuration, should // initialize it in the first and reserved for the all lifecycle. ReservedLdsResourceName = "virtualInbound" // DefaultServerPort if not set port for the server, it will use this. DefaultServerPort = 0 )
const ( ListenerTypeURL = apiTypePrefix + "envoy.config.listener.v3.Listener" RouteTypeURL = apiTypePrefix + "envoy.config.route.v3.RouteConfiguration" ClusterTypeURL = apiTypePrefix + "envoy.config.cluster.v3.Cluster" EndpointTypeURL = apiTypePrefix + "envoy.config.endpoint.v3.ClusterLoadAssignment" SecretTypeURL = apiTypePrefix + "envoy.extensions.transport_sockets.tls.v3.Secret" ExtensionConfigTypeURL = apiTypePrefix + "envoy.config.core.v3.TypedExtensionConfig" RuntimeTypeURL = apiTypePrefix + "envoy.service.runtime.v3.Runtime" HTTPConnManagerTypeURL = apiTypePrefix + "envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager" ThriftProxyTypeURL = apiTypePrefix + "envoy.extensions.filters.network.thrift_proxy.v3.ThriftProxy" RateLimitTypeURL = apiTypePrefix + "envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit" TypedStructTypeURL = apiTypePrefix + "udpa.type.v1.TypedStruct" NameTableTypeURL = apiTypePrefix + "istio.networking.nds.v1.NameTable" // AnyType is used only by ADS AnyType = "" )
Resource types in xDS v3.
Variables ¶
var ( HostName1 = "host1" Port1 = "80" ClusterIP1 = "0.0.0.0" ListenerName1 = HostName1 + ":" + Port1 ReturnedLisName1 = ClusterIP1 + "_" + Port1 ReturnedInbound = "virtualInbound" HostName2 = "host2" Port2 = "8080" ClusterIP2 = "10.0.0.1" ListenerName2 = HostName2 + ":" + Port2 ReturnedLisName2 = ClusterIP2 + "_" + Port2 ReturnedLisName3 = "lis3" InboundListener1 = &v3listenerpb.Listener{ Name: ReturnedInbound, FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{ DestinationPort: wrapperspb.UInt32(80), }, Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(httpConnectionManager1), }, }, }, }, }, } Listener1 = &v3listenerpb.Listener{ Name: ReturnedLisName1, FilterChains: []*v3listenerpb.FilterChain{ { FilterChainMatch: &v3listenerpb.FilterChainMatch{ DestinationPort: wrapperspb.UInt32(80), }, Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(httpConnectionManager1), }, }, { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(thriftProxy), }, }, }, }, }, } Listener2 = &v3listenerpb.Listener{ Name: ReturnedLisName2, FilterChains: []*v3listenerpb.FilterChain{ { Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(httpConnectionManager2), }, }, { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(thriftProxy), }, }, }, }, }, DefaultFilterChain: &v3listenerpb.FilterChain{ Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(thriftProxy), }, }, }, }, } // Listener3 with thrift proxy in FilterChain and DefaultFilterChain Listener3 = &v3listenerpb.Listener{ Name: ReturnedLisName3, FilterChains: []*v3listenerpb.FilterChain{ { Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(thriftProxy), }, }, }, }, }, DefaultFilterChain: &v3listenerpb.FilterChain{ Filters: []*v3listenerpb.Filter{ { ConfigType: &v3listenerpb.Filter_TypedConfig{ TypedConfig: MarshalAny(thriftProxy), }, }, }, }, } )
var ( RouteConfigName1 = "routeConfig1" RouteConfigName2 = "routeConfig2" RouteConfig1 = &v3routepb.RouteConfiguration{ Name: RouteConfigName1, VirtualHosts: []*v3routepb.VirtualHost{ { Name: "vhName", Routes: []*v3routepb.Route{ { Match: &v3routepb.RouteMatch{ PathSpecifier: &v3routepb.RouteMatch_Path{ Path: "path", }, }, Action: &v3routepb.Route_Route{ Route: &v3routepb.RouteAction{ ClusterSpecifier: &v3routepb.RouteAction_WeightedClusters{ WeightedClusters: &v3routepb.WeightedCluster{ Clusters: []*v3routepb.WeightedCluster_ClusterWeight{ { Name: ClusterName1, Weight: &wrapperspb.UInt32Value{ Value: uint32(50), }, }, }, }, }, }, }, }, }, }, }, } RouteConfig2 = &v3routepb.RouteConfiguration{ Name: RouteConfigName2, VirtualHosts: []*v3routepb.VirtualHost{ { Name: "vhName", Routes: []*v3routepb.Route{ { Match: &v3routepb.RouteMatch{ PathSpecifier: &v3routepb.RouteMatch_Path{ Path: "path", }, }, Action: &v3routepb.Route_Route{ Route: &v3routepb.RouteAction{ ClusterSpecifier: &v3routepb.RouteAction_WeightedClusters{ WeightedClusters: &v3routepb.WeightedCluster{ Clusters: []*v3routepb.WeightedCluster_ClusterWeight{ { Name: ClusterName1, Weight: &wrapperspb.UInt32Value{ Value: uint32(50), }, }, }, }, }, }, }, }, }, }, }, } )
var ( ClusterName1 = "cluster1" ClusterName2 = "cluster2" Cluster1 = &v3clusterpb.Cluster{ Name: ClusterName1, ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ ServiceName: EndpointName1, }, LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, OutlierDetection: &v3clusterpb.OutlierDetection{ FailurePercentageThreshold: &wrapperspb.UInt32Value{ Value: 10, }, FailurePercentageRequestVolume: &wrapperspb.UInt32Value{ Value: 100, }, }, LoadAssignment: nil, } Cluster2 = &v3clusterpb.Cluster{ Name: ClusterName2, ClusterDiscoveryType: &v3clusterpb.Cluster_Type{Type: v3clusterpb.Cluster_EDS}, EdsClusterConfig: &v3clusterpb.Cluster_EdsClusterConfig{ ServiceName: EndpointName1, }, OutlierDetection: &v3clusterpb.OutlierDetection{ FailurePercentageThreshold: &wrapperspb.UInt32Value{ Value: 10, }, FailurePercentageRequestVolume: &wrapperspb.UInt32Value{ Value: 0, }, }, LbPolicy: v3clusterpb.Cluster_ROUND_ROBIN, LoadAssignment: nil, } )
Cluster Resource
var ( EndpointName1 = "endpoint1" EndpointName2 = "endpoint2" Endpoints1 = &v3endpointpb.ClusterLoadAssignment{ ClusterName: EndpointName1, Endpoints: []*v3endpointpb.LocalityLbEndpoints{ { LbEndpoints: []*v3endpointpb.LbEndpoint{ { HostIdentifier: &v3endpointpb.LbEndpoint_Endpoint{ Endpoint: &v3endpointpb.Endpoint{ Address: &v3.Address{ Address: &v3.Address_SocketAddress{ SocketAddress: &v3.SocketAddress{ Protocol: v3.SocketAddress_TCP, Address: edsAddr, PortSpecifier: &v3.SocketAddress_PortValue{ PortValue: uint32(edsPort1), }, }, }, }, }, }, LoadBalancingWeight: &wrapperspb.UInt32Value{ Value: uint32(edsWeight1), }, }, { HostIdentifier: &v3endpointpb.LbEndpoint_Endpoint{ Endpoint: &v3endpointpb.Endpoint{ Address: &v3.Address{ Address: &v3.Address_SocketAddress{ SocketAddress: &v3.SocketAddress{ Protocol: v3.SocketAddress_TCP, Address: edsAddr, PortSpecifier: &v3.SocketAddress_PortValue{ PortValue: uint32(edsPort2), }, }, }, }, }, }, LoadBalancingWeight: &wrapperspb.UInt32Value{ Value: uint32(edsWeight2), }, }, }, }, }, } Endpoints2 = &v3endpointpb.ClusterLoadAssignment{ ClusterName: EndpointName2, } )
var NameTable1 = &dnsProto.NameTable{ Table: map[string]*dnsProto.NameTable_NameInfo{ HostName1: { Ips: []string{ClusterIP1}, }, HostName2: { Ips: []string{ClusterIP2}, }, }, }
var ResourceTypeToName = map[ResourceType]string{ ListenerType: "Listener", RouteConfigType: "RouteConfig", ClusterType: "Cluster", EndpointsType: "ClusterLoadAssignment", NameTableType: "NameTable", }
var ResourceTypeToURL = map[ResourceType]string{ ListenerType: ListenerTypeURL, RouteConfigType: RouteTypeURL, ClusterType: ClusterTypeURL, EndpointsType: EndpointTypeURL, NameTableType: NameTableTypeURL, }
var ResourceURLToType = map[string]ResourceType{ ListenerTypeURL: ListenerType, RouteTypeURL: RouteConfigType, ClusterTypeURL: ClusterType, EndpointTypeURL: EndpointsType, NameTableTypeURL: NameTableType, }
Functions ¶
func UnmarshalLDS ¶
func UnmarshalLDS(rawResources []*anypb.Any) (map[string]*ListenerResource, error)
UnmarshalLDS unmarshalls the LDS Response. Only focus on OutboundListener now. Get the InlineRouteConfig or RouteConfigName from the listener.
Types ¶
type ClusterDiscoveryType ¶
type ClusterDiscoveryType int
const ( ClusterDiscoveryTypeEDS ClusterDiscoveryType = iota ClusterDiscoveryTypeLogicalDNS ClusterDiscoveryTypeStatic )
func (ClusterDiscoveryType) String ¶
func (d ClusterDiscoveryType) String() string
type ClusterLbPolicy ¶
type ClusterLbPolicy int
const ( ClusterLbRoundRobin ClusterLbPolicy = iota ClusterLbRingHash )
func (ClusterLbPolicy) String ¶
func (p ClusterLbPolicy) String() string
type ClusterResource ¶
type ClusterResource struct { DiscoveryType ClusterDiscoveryType LbPolicy ClusterLbPolicy EndpointName string InlineEndpoints *EndpointsResource OutlierDetection *OutlierDetection }
func (*ClusterResource) InlineEDS ¶
func (c *ClusterResource) InlineEDS() *EndpointsResource
func (*ClusterResource) MarshalJSON ¶
func (c *ClusterResource) MarshalJSON() ([]byte, error)
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
func (*Endpoint) MarshalJSON ¶
type EndpointsResource ¶
type EndpointsResource struct {
Localities []*Locality
}
type ExactMatcher ¶ added in v0.3.0
type ExactMatcher string
func (ExactMatcher) Match ¶ added in v0.3.0
func (em ExactMatcher) Match(other string) bool
type HTTPRouteConfig ¶
type HTTPRouteConfig struct {
VirtualHosts []*VirtualHost
}
type HTTPRouteMatch ¶
func (*HTTPRouteMatch) MatchMeta ¶ added in v0.3.0
func (rm *HTTPRouteMatch) MatchMeta(md map[string]string) bool
func (*HTTPRouteMatch) MatchPath ¶
func (rm *HTTPRouteMatch) MatchPath(path string) bool
type ListenerResource ¶
type ListenerResource struct {
NetworkFilters []*NetworkFilter
}
ListenerResource is the resource parsed from the lds response. Only includes NetworkFilters now
func (*ListenerResource) ResourceType ¶ added in v0.2.0
func (r *ListenerResource) ResourceType() ResourceType
type Matchers ¶ added in v0.3.0
func BuildMatchers ¶ added in v0.3.0
func BuildMatchers(headers []*v3.HeaderMatcher) Matchers
BuildMatchers build matcher set from headers
type NDSResource ¶
func UnmarshalNDS ¶
func UnmarshalNDS(rawResources []*anypb.Any) (*NDSResource, error)
type NetworkFilter ¶
type NetworkFilter struct { FilterType NetworkFilterType RouteConfigName string RoutePort uint32 InlineRouteConfig *RouteConfigResource }
NetworkFilter contains the network filter config we need got from Listener.FilterChains. Only support HttpConnectionManager and ThriftProxy. If InlineRouteConfig is not nil, use it to perform routing. Or, use RouteConfigName as the resourceName to get the RouteConfigResource.
type NetworkFilterType ¶
type NetworkFilterType int
const ( NetworkFilterTypeHTTP NetworkFilterType = iota NetworkFilterTypeThrift )
type OutlierDetection ¶ added in v0.4.0
type PrefixMatcher ¶ added in v0.3.0
type PrefixMatcher string
func (PrefixMatcher) Match ¶ added in v0.3.0
func (pm PrefixMatcher) Match(other string) bool
type RegexMatcher ¶ added in v0.3.0
type RegexMatcher struct {
// contains filtered or unexported fields
}
func (*RegexMatcher) Match ¶ added in v0.3.0
func (rm *RegexMatcher) Match(other string) bool
type ResourceMeta ¶
ResourceMeta records the meta information of a resource.
type ResourceType ¶
type ResourceType int
const ( UnknownResource ResourceType = iota ListenerType RouteConfigType ClusterType EndpointsType NameTableType )
func (ResourceType) RequireFullADSResponse ¶ added in v0.2.0
func (rt ResourceType) RequireFullADSResponse() bool
RequireFullADSResponse returns if a full response is required for every update.
type RetryBackOff ¶ added in v0.4.0
type RetryPolicy ¶ added in v0.4.0
type Route ¶
type Route struct { Match RouteMatch WeightedClusters []*WeightedCluster Timeout time.Duration RetryPolicy RetryPolicy }
func (*Route) MarshalJSON ¶
type RouteConfigResource ¶
type RouteConfigResource struct { HTTPRouteConfig *HTTPRouteConfig ThriftRouteConfig *ThriftRouteConfig MaxTokens uint32 TokensPerFill uint32 }
RouteConfigResource is used for routing HTTPRouteConfig is the native http route config, which consists of a list of virtual hosts. ThriftRouteConfig is converted from the routeConfiguration in thrift proxy, which can only be configured in the listener filter For details of thrift_proxy, please refer to: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/thrift_proxy/v3/route.proto#envoy-v3-api-msg-extensions-filters-network-thrift-proxy-v3-routeconfiguration
type RouteMatch ¶
type ThriftRouteConfig ¶
type ThriftRouteConfig struct {
Routes []*Route
}
type ThriftRouteMatch ¶
func (*ThriftRouteMatch) MatchMeta ¶ added in v0.3.0
func (tm *ThriftRouteMatch) MatchMeta(md map[string]string) bool
func (*ThriftRouteMatch) MatchPath ¶
func (tm *ThriftRouteMatch) MatchPath(path string) bool
type VirtualHost ¶
type WeightedCluster ¶
type XDSUpdateHandler ¶ added in v0.4.0
XDSUpdateHandler is the callback function when one type resource is updated.