Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAllowAnyVHost() *route.VirtualHost
- func BuildCommonRouteMatch(routeMatch *route.RouteMatch, source *traffic_manage.SourceService)
- func BuildOnDemandRouteTypedPerFilterConfig() *anypb.Any
- func BuildRateLimitActionHeaderValueMatch(key, value string, arguments ...*apitraffic.MatchArgument) *route.RateLimit_Action_HeaderValueMatch
- func BuildRateLimitActionQueryParameterValueMatch(key string, arg *apitraffic.MatchArgument) *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 DumpSnapShotJSON(snapshot cache.ResourceSnapshot) []byte
- func EnableTLS(t TLSMode) bool
- 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 GetEnvoyMetaField[T any](meta *_struct.Struct, fileName string, fType T) (T, bool)
- func Init()
- func IsNormalEndpoint(ins *apiservice.Instance) bool
- func MakeDefaultFilterChain() *listenerv3.FilterChain
- func MakeDefaultRoute(trafficDirection corev3.TrafficDirection, svcKey model.ServiceKey, ...) *route.Route
- func MakeGatewayBoundHCM(svcKey model.ServiceKey, opt *BuildOption) *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 MakeInBoundRouteConfigName(svcKey model.ServiceKey, demand bool) string
- 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 MakeSidecarOnDemandOutBoundHCM(svcKey model.ServiceKey, option *BuildOption) *hcm.HttpConnectionManager
- func MakeSidecarRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, ...) *route.Route
- func MakeTLSTransportSocket(ctx proto.Message) *core.TransportSocket
- func MakeVHDSServiceName(prefix string, svcKey model.ServiceKey) string
- func MustNewAny(src proto.Message) *anypb.Any
- func ParseNodeID(nodeID string) (runType, polarisNamespace, uuid, hostIP string)
- func SupportTLS(x XDSType) bool
- func ToJSONArray(resources map[string]types.Resource) []json.RawMessage
- func ToYamlArray(resources map[string]types.Resource) []json.RawMessage
- func YamlEncode(any interface{}) []byte
- type BuildOption
- type EnvoyNodeView
- type PolarisNodeHash
- type RegisterService
- type RunType
- type ServiceInfo
- type TLSMode
- type XDSBuilder
- type XDSClient
- func (n *XDSClient) GetNodeID() string
- func (n *XDSClient) GetRegisterServices() []*RegisterService
- func (n *XDSClient) GetSelfNamespace() string
- func (n *XDSClient) GetSelfService() string
- func (n *XDSClient) GetSelfServiceKey() model.ServiceKey
- func (n *XDSClient) IsGateway() bool
- func (n *XDSClient) ResourceKey() string
- func (n *XDSClient) String() string
- 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) HasEnvoyNodes() bool
- func (x *XDSNodeManager) ListEnvoyNodes() []*XDSClient
- func (x *XDSNodeManager) ListEnvoyNodesView(run RunType) []*EnvoyNodeView
- 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" OdcdsRouteConfigName = "polaris-odcds-router" InternalOdcdsHeader = "internal-service-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" // SidecarRegisterService xds metadata key when node what register service from envoy healthcheck // value example: [{"name":"","ports":{"TCP":[8080],"DUBBO":[28080]},"health_check_path":"","health_check_port":8080,"health_check_ttl":5}] SidecarRegisterService = "sidecar.polarismesh.cn/registerServices" // SidecarTLSModeTag . SidecarTLSModeTag = "sidecar.polarismesh.cn/tlsMode" // SidecarOpenOnDemandFeature . SidecarOpenOnDemandFeature = "sidecar.polarismesh.cn/openOnDemand" // SidecarOpenOnDemandServer . SidecarOpenOnDemandServer = "sidecar.polarismesh.cn/demandServer" )
View Source
const (
EnvoyHttpFilter_OnDemand = "envoy.filters.http.on_demand"
)
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{}, }
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 BuildOnDemandRouteTypedPerFilterConfig ¶ added in v1.18.0
func BuildRateLimitActionHeaderValueMatch ¶
func BuildRateLimitActionHeaderValueMatch(key, value string, arguments ...*apitraffic.MatchArgument) *route.RateLimit_Action_HeaderValueMatch
func BuildRateLimitActionQueryParameterValueMatch ¶
func BuildRateLimitActionQueryParameterValueMatch(key string, arg *apitraffic.MatchArgument) *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, opt *BuildOption) *route.WeightedCluster
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 GetEnvoyMetaField ¶ added in v1.18.0
func IsNormalEndpoint ¶
func IsNormalEndpoint(ins *apiservice.Instance) bool
func MakeDefaultFilterChain ¶
func MakeDefaultFilterChain() *listenerv3.FilterChain
func MakeDefaultRoute ¶
func MakeDefaultRoute(trafficDirection corev3.TrafficDirection, svcKey model.ServiceKey, opt *BuildOption) *route.Route
默认路由
func MakeGatewayBoundHCM ¶
func MakeGatewayBoundHCM(svcKey model.ServiceKey, opt *BuildOption) *hcm.HttpConnectionManager
func MakeGatewayRoute ¶
func MakeGatewayRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, destinations []*traffic_manage.DestinationGroup, opt *BuildOption) *route.Route
func MakeHealthCheck ¶
func MakeHealthCheck(serviceInfo *ServiceInfo) []*core.HealthCheck
Translate the FaultDetector configuration of Polaris into HealthCheck
func MakeInBoundRouteConfigName ¶ added in v1.18.0
func MakeInBoundRouteConfigName(svcKey model.ServiceKey, demand bool) string
MakeInBoundRouteConfigName .
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, opt *BuildOption) string
MakeServiceName .
func MakeSidecarBoundHCM ¶
func MakeSidecarBoundHCM(svcKey model.ServiceKey, trafficDirection corev3.TrafficDirection, opt *BuildOption) *hcm.HttpConnectionManager
func MakeSidecarLocalRateLimit ¶
func MakeSidecarLocalRateLimit(rateLimitCache types.RateLimitCache, svcKey model.ServiceKey) ([]*route.RateLimit, map[string]*anypb.Any, error)
func MakeSidecarOnDemandOutBoundHCM ¶ added in v1.18.0
func MakeSidecarOnDemandOutBoundHCM(svcKey model.ServiceKey, option *BuildOption) *hcm.HttpConnectionManager
func MakeSidecarRoute ¶
func MakeSidecarRoute(trafficDirection corev3.TrafficDirection, routeMatch *route.RouteMatch, svcInfo *ServiceInfo, destinations []*traffic_manage.DestinationGroup, opt *BuildOption) *route.Route
func MakeTLSTransportSocket ¶
func MakeTLSTransportSocket(ctx proto.Message) *core.TransportSocket
func MakeVHDSServiceName ¶ added in v1.18.0
func MakeVHDSServiceName(prefix string, svcKey model.ServiceKey) string
MakeVHDSServiceName .
func ParseNodeID ¶
func SupportTLS ¶ added in v1.18.0
func ToJSONArray ¶
func ToJSONArray(resources map[string]types.Resource) []json.RawMessage
func ToYamlArray ¶ added in v1.18.0
func ToYamlArray(resources map[string]types.Resource) []json.RawMessage
func YamlEncode ¶
func YamlEncode(any interface{}) []byte
Types ¶
type BuildOption ¶
type BuildOption struct { RunType RunType Namespace string TLSMode TLSMode Services map[model.ServiceKey]*ServiceInfo // SelfService 当前服务信息,只有处理 INBOUND 级别的信息才能设置 SelfService model.ServiceKey // 不是必须,只有在 EDS 生成,并且是处理 INBOUND 的时候才会设置 Client *XDSClient // TrafficDirection 设置流量的出入方向,INBOUND|OUTBOUND TrafficDirection corev3.TrafficDirection // ForceDelete 如果设置了该字段值为 true, 则不会真正执行 XDS 的构建工作, 仅仅生成对应资源的 Name 名称用于清理 ForceDelete bool // contains filtered or unexported fields }
func (*BuildOption) Clone ¶
func (opt *BuildOption) Clone() *BuildOption
func (*BuildOption) CloseEnvoyDemand ¶ added in v1.18.0
func (opt *BuildOption) CloseEnvoyDemand()
func (*BuildOption) HasTls ¶ added in v1.18.0
func (opt *BuildOption) HasTls() bool
func (*BuildOption) IsDemand ¶ added in v1.18.0
func (opt *BuildOption) IsDemand() bool
func (*BuildOption) OpenEnvoyDemand ¶ added in v1.18.0
func (opt *BuildOption) OpenEnvoyDemand()
type EnvoyNodeView ¶ added in v1.18.0
type PolarisNodeHash ¶
type PolarisNodeHash struct {
NodeMgr *XDSNodeManager
}
PolarisNodeHash 存放 hash 方法
type RegisterService ¶ added in v1.18.0
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) Equal ¶ added in v1.18.0
func (s *ServiceInfo) Equal(o *ServiceInfo) bool
func (*ServiceInfo) MatchService ¶
func (s *ServiceInfo) MatchService(ns, name string) bool
type XDSBuilder ¶
type XDSBuilder interface { // Init Init(service.DiscoverServer) // Generate Generate(option *BuildOption) (interface{}, error) }
XDSBuilder .
type XDSClient ¶
type XDSClient struct { ID string RunType RunType User string Namespace string IPAddr string PodIP string Metadata map[string]string Version string Node *core.Node TLSMode TLSMode OpenOnDemand bool DemandServer string }
XDSClient 客户端代码结构体
func ParseXDSClient ¶ added in v1.18.0
ParseXDSClient .
func (*XDSClient) GetRegisterServices ¶ added in v1.18.0
func (n *XDSClient) GetRegisterServices() []*RegisterService
func (*XDSClient) GetSelfNamespace ¶
GetSelfNamespace 获取 envoy 对应的 namespace 信息
func (*XDSClient) GetSelfService ¶
GetSelfService 获取 envoy 对应的 service 信息
func (*XDSClient) GetSelfServiceKey ¶ added in v1.18.0
func (n *XDSClient) GetSelfServiceKey() model.ServiceKey
GetSelfServiceKey 获取 envoy 对应的 service 信息
func (*XDSClient) ResourceKey ¶ added in v1.18.0
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) HasEnvoyNodes ¶ added in v1.18.0
func (x *XDSNodeManager) HasEnvoyNodes() bool
func (*XDSNodeManager) ListEnvoyNodes ¶ added in v1.18.0
func (x *XDSNodeManager) ListEnvoyNodes() []*XDSClient
func (*XDSNodeManager) ListEnvoyNodesView ¶ added in v1.18.0
func (x *XDSNodeManager) ListEnvoyNodesView(run RunType) []*EnvoyNodeView
func (*XDSNodeManager) ListGatewayNodes ¶
func (x *XDSNodeManager) ListGatewayNodes() []*XDSClient
func (*XDSNodeManager) ListSidecarNodes ¶
func (x *XDSNodeManager) ListSidecarNodes() []*XDSClient
type XDSType ¶
type XDSType int16
const ( LDS XDSType RDS EDS CDS RLS SDS VHDS UnknownXDS )
func FormatTypeUrl ¶ added in v1.18.0
func FromSimpleXDS ¶ added in v1.18.0
func (XDSType) ResourceType ¶ added in v1.18.0
func (x XDSType) ResourceType() resourcev3.Type
Click to show internal directories.
Click to hide internal directories.