Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAllowAnyVHost() *route.VirtualHost
- func BuildCommonRouteMatch(routeMatch *route.RouteMatch, source *traffic_manage.SourceService)
- func BuildRateLimitActionHeaderValueMatch(key string, argument *apitraffic.MatchArgument) *route.RateLimit_Action_HeaderValueMatch
- func BuildRateLimitActionQueryParameterValueMatch(key string, value *apimodel.MatchString) *route.RateLimit_Action_QueryParameterValueMatch
- func BuildRateLimitConf(prefix string) *lrl.LocalRateLimit
- func BuildRateLimitDescriptors(rule *traffic_manage.Rule) ([]*route.RateLimit_Action, []*ratelimitv32.LocalRateLimitDescriptor)
- func BuildSidecarRouteMatch(routeMatch *route.RouteMatch, source *traffic_manage.SourceService)
- func BuildWeightClustersV2(trafficDirection corev3.TrafficDirection, ...) *route.WeightedCluster
- func DumpSnapShot(snapshot cache.ResourceSnapshot) []byte
- func DumpSnapShotJSON(snapshot cache.ResourceSnapshot) []byte
- func FilterInboundRouterRule(svc *ServiceInfo) []*traffic_manage.SubRuleRouting
- func FormatEndpointHealth(ins *apiservice.Instance) core.HealthStatus
- func GenEndpointMetaFromPolarisIns(ins *apiservice.Instance) *core.Metadata
- func GenerateServiceDomains(serviceInfo *ServiceInfo) []string
- func IsNormalEndpoint(ins *apiservice.Instance) bool
- func MakeDefaultFilterChain() *listenerv3.FilterChain
- func MakeDefaultRoute(trafficDirection corev3.TrafficDirection, svcKey model.ServiceKey) *route.Route
- func MakeGatewayBoundHCM() *hcm.HttpConnectionManager
- func MakeGatewayLocalRateLimit(rateLimitCache types.RateLimitCache, pathSpecifier string, ...) ([]*route.RateLimit, map[string]*anypb.Any, error)
- func MakeGatewayRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, ...) *route.Route
- func MakeHealthCheck(serviceInfo *ServiceInfo) []*core.HealthCheck
- func MakeLbSubsetConfig(serviceInfo *ServiceInfo) *cluster.Cluster_LbSubsetConfig
- func MakeOutlierDetection(serviceInfo *ServiceInfo) *cluster.OutlierDetection
- func MakeServiceGatewayDomains() []string
- func MakeServiceName(svcKey model.ServiceKey, trafficDirection corev3.TrafficDirection) string
- func MakeSidecarBoundHCM(svcKey model.ServiceKey, trafficDirection corev3.TrafficDirection) *hcm.HttpConnectionManager
- func MakeSidecarLocalRateLimit(rateLimitCache types.RateLimitCache, svcKey model.ServiceKey) ([]*route.RateLimit, map[string]*anypb.Any, error)
- func MakeSidecarRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, ...) *route.Route
- func MakeTLSTransportSocket(ctx proto.Message) *core.TransportSocket
- func MustNewAny(src proto.Message) *anypb.Any
- func ParseNodeID(nodeID string) (runType, polarisNamespace, uuid, hostIP string)
- func ToJSONArray(resources map[string]types.Resource) []json.RawMessage
- func YamlEncode(any interface{}) []byte
- type BuildOption
- type Callbacks
- func (cb *Callbacks) OnDeltaStreamClosed(id int64, node *corev3.Node)
- func (cb *Callbacks) OnDeltaStreamOpen(_ context.Context, id int64, typ string) error
- func (cb *Callbacks) OnFetchRequest(_ context.Context, req *discovery.DiscoveryRequest) error
- func (cb *Callbacks) OnFetchResponse(req *discovery.DiscoveryRequest, resp *discovery.DiscoveryResponse)
- func (cb *Callbacks) OnStreamClosed(id int64, node *corev3.Node)
- func (cb *Callbacks) OnStreamDeltaRequest(id int64, req *discovery.DeltaDiscoveryRequest) error
- func (cb *Callbacks) OnStreamDeltaResponse(id int64, req *discovery.DeltaDiscoveryRequest, ...)
- func (cb *Callbacks) OnStreamOpen(_ context.Context, id int64, typ string) error
- func (cb *Callbacks) OnStreamRequest(id int64, req *discovery.DiscoveryRequest) error
- func (cb *Callbacks) OnStreamResponse(_ context.Context, id int64, req *discovery.DiscoveryRequest, ...)
- func (cb *Callbacks) Report()
- type PolarisNodeHash
- type RunType
- type ServiceInfo
- type TLSMode
- type XDSBuilder
- type XDSClient
- type XDSNodeManager
- func (x *XDSNodeManager) AddNodeIfAbsent(streamId int64, node *core.Node)
- func (x *XDSNodeManager) DelNode(streamId int64)
- func (x *XDSNodeManager) GetNode(id string) *XDSClient
- func (x *XDSNodeManager) GetNodeByStreamID(streamId int64) *XDSClient
- func (x *XDSNodeManager) ListGatewayNodes() []*XDSClient
- func (x *XDSNodeManager) ListSidecarNodes() []*XDSClient
- type XDSType
Constants ¶
View Source
const ( PassthroughClusterName = "PassthroughCluster" RouteConfigName = "polaris-router" OutBoundRouteConfigName = "polaris-outbound-router" InBoundRouteConfigName = "polaris-inbound-cluster" )
View Source
const ( // LocalRateLimitStage envoy local ratelimit stage LocalRateLimitStage = 0 // DistributedRateLimitStage envoy remote ratelimit stage DistributedRateLimitStage = 1 )
View Source
const ( K8sDnsResolveSuffixSvc = ".svc" K8sDnsResolveSuffixSvcCluster = ".svc.cluster" K8sDnsResolveSuffixSvcClusterLocal = ".svc.cluster.local" )
View Source
const ( // GatewayNamespaceName xds metadata key when node is run in gateway mode GatewayNamespaceName = "gateway.polarismesh.cn/serviceNamespace" // GatewayNamespaceName xds metadata key when node is run in gateway mode GatewayServiceName = "gateway.polarismesh.cn/serviceName" // OldGatewayNamespaceName xds metadata key when node is run in gateway mode OldGatewayNamespaceName = "gateway_namespace" // OldGatewayServiceName xds metadata key when node is run in gateway mode OldGatewayServiceName = "gateway_service" // SidecarServiceName xds metadata key when node is run in sidecar mode SidecarServiceName = "sidecar.polarismesh.cn/serviceName" // SidecarNamespaceName xds metadata key when node is run in sidecar mode SidecarNamespaceName = "sidecar.polarismesh.cn/serviceNamespace" // SidecarBindPort xds metadata key when node is run in sidecar mode SidecarBindPort = "sidecar.polarismesh.cn/bindPorts" )
View Source
const ( // 这个是特殊指定的 prefix MatchString_Prefix = apimodel.MatchString_MatchStringType(-1) )
Variables ¶
View Source
var DefaultSdsConfig = &core.ConfigSource{ ConfigSourceSpecifier: &core.ConfigSource_ApiConfigSource{ ApiConfigSource: &core.ApiConfigSource{ ApiType: core.ApiConfigSource_GRPC, TransportApiVersion: core.ApiVersion_V3, GrpcServices: []*core.GrpcService{ { TargetSpecifier: &core.GrpcService_EnvoyGrpc_{ EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ ClusterName: "sds-grpc", }, }, }, }, SetNodeOnFirstMessageOnly: true, }, }, InitialFetchTimeout: &duration.Duration{}, ResourceApiVersion: core.ApiVersion_V3, }
View Source
var InboundCommonTLSContext = &tlstrans.CommonTlsContext{ TlsParams: &tlstrans.TlsParameters{ TlsMinimumProtocolVersion: tlstrans.TlsParameters_TLSv1_2, CipherSuites: []string{ "ECDHE-ECDSA-AES256-GCM-SHA384", "ECDHE-RSA-AES256-GCM-SHA384", "ECDHE-ECDSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256", "AES256-GCM-SHA384", "AES128-GCM-SHA256", }, }, TlsCertificateSdsSecretConfigs: []*tlstrans.SdsSecretConfig{ { Name: "default", SdsConfig: DefaultSdsConfig, }, }, ValidationContextType: &tlstrans.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &tlstrans.CommonTlsContext_CombinedCertificateValidationContext{ DefaultValidationContext: &tlstrans.CertificateValidationContext{ MatchSubjectAltNames: []*matcherv3.StringMatcher{ { MatchPattern: &matcherv3.StringMatcher_Prefix{ Prefix: "spiffe://cluster.local/", }, }, }, }, ValidationContextSdsSecretConfig: &tlstrans.SdsSecretConfig{ Name: "ROOTCA", SdsConfig: DefaultSdsConfig, }, }, }, }
View Source
var MTLSTransportSocketMatch = &structpb.Struct{ Fields: map[string]*structpb.Value{ "acceptMTLS": {Kind: &structpb.Value_StringValue{StringValue: "true"}}, }, }
View Source
var OutboundCommonTLSContext = &tlstrans.CommonTlsContext{ TlsCertificateSdsSecretConfigs: []*tlstrans.SdsSecretConfig{ { Name: "default", SdsConfig: DefaultSdsConfig, }, }, ValidationContextType: &tlstrans.CommonTlsContext_CombinedValidationContext{ CombinedValidationContext: &tlstrans.CommonTlsContext_CombinedCertificateValidationContext{ DefaultValidationContext: &tlstrans.CertificateValidationContext{}, ValidationContextSdsSecretConfig: &tlstrans.SdsSecretConfig{ Name: "ROOTCA", SdsConfig: DefaultSdsConfig, }, }, }, }
View Source
var PassthroughCluster = &cluster.Cluster{ Name: PassthroughClusterName, ConnectTimeout: durationpb.New(5 * time.Second), ClusterDiscoveryType: &cluster.Cluster_Type{Type: cluster.Cluster_ORIGINAL_DST}, LbPolicy: cluster.Cluster_CLUSTER_PROVIDED, CircuitBreakers: &cluster.CircuitBreakers{ Thresholds: []*cluster.CircuitBreakers_Thresholds{ { MaxConnections: &wrappers.UInt32Value{Value: math.MaxUint32}, MaxPendingRequests: &wrappers.UInt32Value{Value: math.MaxUint32}, MaxRequests: &wrappers.UInt32Value{Value: math.MaxUint32}, MaxRetries: &wrappers.UInt32Value{Value: math.MaxUint32}, }, }, }, }
View Source
var ( TrafficBoundRoute = map[corev3.TrafficDirection]string{ corev3.TrafficDirection_INBOUND: InBoundRouteConfigName, corev3.TrafficDirection_OUTBOUND: OutBoundRouteConfigName, } )
Functions ¶
func BuildAllowAnyVHost ¶
func BuildAllowAnyVHost() *route.VirtualHost
func BuildCommonRouteMatch ¶
func BuildCommonRouteMatch(routeMatch *route.RouteMatch, source *traffic_manage.SourceService)
func BuildRateLimitActionHeaderValueMatch ¶
func BuildRateLimitActionHeaderValueMatch(key string, argument *apitraffic.MatchArgument) *route.RateLimit_Action_HeaderValueMatch
func BuildRateLimitActionQueryParameterValueMatch ¶
func BuildRateLimitActionQueryParameterValueMatch(key string, value *apimodel.MatchString) *route.RateLimit_Action_QueryParameterValueMatch
func BuildRateLimitConf ¶
func BuildRateLimitConf(prefix string) *lrl.LocalRateLimit
func BuildRateLimitDescriptors ¶
func BuildRateLimitDescriptors(rule *traffic_manage.Rule) ([]*route.RateLimit_Action, []*ratelimitv32.LocalRateLimitDescriptor)
func BuildSidecarRouteMatch ¶
func BuildSidecarRouteMatch(routeMatch *route.RouteMatch, source *traffic_manage.SourceService)
func BuildWeightClustersV2 ¶
func BuildWeightClustersV2(trafficDirection corev3.TrafficDirection, destinations []*traffic_manage.DestinationGroup) *route.WeightedCluster
func DumpSnapShot ¶
func DumpSnapShot(snapshot cache.ResourceSnapshot) []byte
func DumpSnapShotJSON ¶
func DumpSnapShotJSON(snapshot cache.ResourceSnapshot) []byte
func FilterInboundRouterRule ¶
func FilterInboundRouterRule(svc *ServiceInfo) []*traffic_manage.SubRuleRouting
func FormatEndpointHealth ¶
func FormatEndpointHealth(ins *apiservice.Instance) core.HealthStatus
func GenEndpointMetaFromPolarisIns ¶
func GenEndpointMetaFromPolarisIns(ins *apiservice.Instance) *core.Metadata
func GenerateServiceDomains ¶
func GenerateServiceDomains(serviceInfo *ServiceInfo) []string
func IsNormalEndpoint ¶
func IsNormalEndpoint(ins *apiservice.Instance) bool
func MakeDefaultFilterChain ¶
func MakeDefaultFilterChain() *listenerv3.FilterChain
func MakeDefaultRoute ¶
func MakeDefaultRoute(trafficDirection corev3.TrafficDirection, svcKey model.ServiceKey) *route.Route
默认路由
func MakeGatewayBoundHCM ¶
func MakeGatewayBoundHCM() *hcm.HttpConnectionManager
func MakeGatewayRoute ¶
func MakeGatewayRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, destinations []*traffic_manage.DestinationGroup) *route.Route
func MakeHealthCheck ¶
func MakeHealthCheck(serviceInfo *ServiceInfo) []*core.HealthCheck
Translate the FaultDetector configuration of Polaris into HealthCheck
func MakeLbSubsetConfig ¶
func MakeLbSubsetConfig(serviceInfo *ServiceInfo) *cluster.Cluster_LbSubsetConfig
func MakeOutlierDetection ¶
func MakeOutlierDetection(serviceInfo *ServiceInfo) *cluster.OutlierDetection
Translate the circuit breaker configuration of Polaris into OutlierDetection
func MakeServiceGatewayDomains ¶
func MakeServiceGatewayDomains() []string
func MakeServiceName ¶
func MakeServiceName(svcKey model.ServiceKey, trafficDirection corev3.TrafficDirection) string
func MakeSidecarBoundHCM ¶
func MakeSidecarBoundHCM(svcKey model.ServiceKey, trafficDirection corev3.TrafficDirection) *hcm.HttpConnectionManager
func MakeSidecarLocalRateLimit ¶
func MakeSidecarLocalRateLimit(rateLimitCache types.RateLimitCache, svcKey model.ServiceKey) ([]*route.RateLimit, map[string]*anypb.Any, error)
func MakeSidecarRoute ¶
func MakeSidecarRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, svcInfo *ServiceInfo, destinations []*traffic_manage.DestinationGroup) *route.Route
func MakeTLSTransportSocket ¶
func MakeTLSTransportSocket(ctx proto.Message) *core.TransportSocket
func ParseNodeID ¶
func ToJSONArray ¶
func ToJSONArray(resources map[string]types.Resource) []json.RawMessage
func YamlEncode ¶
func YamlEncode(any interface{}) []byte
Types ¶
type BuildOption ¶
type BuildOption struct { Namespace string TLSMode TLSMode Services map[model.ServiceKey]*ServiceInfo VersionLocal string }
func (*BuildOption) Clone ¶
func (opt *BuildOption) Clone() *BuildOption
type Callbacks ¶
type Callbacks struct {
// contains filtered or unexported fields
}
func NewCallback ¶
func NewCallback(log *commonlog.Scope, nodeMgr *XDSNodeManager) *Callbacks
func (*Callbacks) OnDeltaStreamClosed ¶
func (*Callbacks) OnDeltaStreamOpen ¶
func (*Callbacks) OnFetchRequest ¶
func (*Callbacks) OnFetchResponse ¶
func (cb *Callbacks) OnFetchResponse(req *discovery.DiscoveryRequest, resp *discovery.DiscoveryResponse)
func (*Callbacks) OnStreamDeltaRequest ¶
func (cb *Callbacks) OnStreamDeltaRequest(id int64, req *discovery.DeltaDiscoveryRequest) error
func (*Callbacks) OnStreamDeltaResponse ¶
func (cb *Callbacks) OnStreamDeltaResponse(id int64, req *discovery.DeltaDiscoveryRequest, resp *discovery.DeltaDiscoveryResponse)
func (*Callbacks) OnStreamOpen ¶
func (*Callbacks) OnStreamRequest ¶
func (cb *Callbacks) OnStreamRequest(id int64, req *discovery.DiscoveryRequest) error
func (*Callbacks) OnStreamResponse ¶
func (cb *Callbacks) OnStreamResponse(_ context.Context, id int64, req *discovery.DiscoveryRequest, resp *discovery.DiscoveryResponse)
type PolarisNodeHash ¶
type PolarisNodeHash struct {
NodeMgr *XDSNodeManager
}
PolarisNodeHash 存放 hash 方法
func (PolarisNodeHash) ID ¶
func (PolarisNodeHash) ID(node *core.Node) string
ID id 的格式是 ${sidecar|gateway}~namespace/uuid~hostIp case 1: envoy 为 sidecar 模式时,则 NodeID 的格式为以下两种
eg 1. namespace/uuid~hostIp eg 2. sidecar~namespace/uuid-hostIp eg 3. envoy_node_id="${NAMESPACE}/${INSTANCE_IP}~${POD_NAME}"
case 2: envoy 为 gateway 模式时,则 NodeID 的格式为: gateway~namespace/uuid~hostIp
type ServiceInfo ¶
type ServiceInfo struct { ID string Name string Namespace string ServiceKey model.ServiceKey AliasFor *model.Service Instances []*apiservice.Instance SvcInsRevision string Routing *traffic_manage.Routing SvcRoutingRevision string Ports []*model.ServicePort RateLimit *traffic_manage.RateLimit SvcRateLimitRevision string CircuitBreaker *fault_tolerance.CircuitBreaker CircuitBreakerRevision string FaultDetect *fault_tolerance.FaultDetector FaultDetectRevision string }
ServiceInfo 北极星服务结构体
func (*ServiceInfo) MatchService ¶
func (s *ServiceInfo) MatchService(ns, name string) bool
type XDSBuilder ¶
type XDSBuilder interface { // Init Init(*XDSClient, service.DiscoverServer) // Generate Generate(option *BuildOption) (interface{}, error) }
XDSBuilder .
type XDSClient ¶
type XDSClient struct { RunType RunType User string Namespace string IPAddr string PodIP string Metadata map[string]string Version string Node *core.Node TLSMode TLSMode }
XDSClient 客户端代码结构体
func (*XDSClient) GetSelfNamespace ¶
GetSelfNamespace 获取 envoy 对应的 namespace 信息
func (*XDSClient) GetSelfService ¶
GetSelfService 获取 envoy 对应的 service 信息
type XDSNodeManager ¶
type XDSNodeManager struct {
// contains filtered or unexported fields
}
func NewXDSNodeManager ¶
func NewXDSNodeManager() *XDSNodeManager
func (*XDSNodeManager) AddNodeIfAbsent ¶
func (x *XDSNodeManager) AddNodeIfAbsent(streamId int64, node *core.Node)
func (*XDSNodeManager) DelNode ¶
func (x *XDSNodeManager) DelNode(streamId int64)
func (*XDSNodeManager) GetNode ¶
func (x *XDSNodeManager) GetNode(id string) *XDSClient
func (*XDSNodeManager) GetNodeByStreamID ¶
func (x *XDSNodeManager) GetNodeByStreamID(streamId int64) *XDSClient
func (*XDSNodeManager) ListGatewayNodes ¶
func (x *XDSNodeManager) ListGatewayNodes() []*XDSClient
func (*XDSNodeManager) ListSidecarNodes ¶
func (x *XDSNodeManager) ListSidecarNodes() []*XDSClient
Source Files ¶
Click to show internal directories.
Click to hide internal directories.