You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/09/20 03:13:46 UTC
[dubbo-go-pixiu] branch develop updated: deploy pixiu as dubbo service egress gateway in k8s istio (#446)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git
The following commit(s) were added to refs/heads/develop by this push:
new cdbae995 deploy pixiu as dubbo service egress gateway in k8s istio (#446)
cdbae995 is described below
commit cdbae995c91c9a9b4e62c71a07c8348c84de6ff0
Author: ma642 <ma...@126.com>
AuthorDate: Tue Sep 20 11:13:40 2022 +0800
deploy pixiu as dubbo service egress gateway in k8s istio (#446)
* tmp use aagreate xds
* add istio support
* use pixiu-api
* runable xds istio
* fix xds issue
* use google protobuf package
* format imports
* add logger for unsupport discover type
* get ip from env
* move to pixiu/pkg
* rename istio
* fix issue readDubboServiceFromListener
* fix ci issue
* fix ci issue
Co-authored-by: mazhihui <ma...@unipus.cn>
Co-authored-by: mazhihui <ma...@baimaohui.net>
---
.gitignore | 3 +-
go.mod | 2 +-
go.sum | 4 +-
pixiu/pkg/adapter/dubboregistry/registry/util.go | 1 -
.../zookeeper/application_service_listener.go | 2 -
pixiu/pkg/config/xds/apiclient/apiclient.go | 7 +
pixiu/pkg/config/xds/apiclient/grpc.go | 78 ++--
pixiu/pkg/config/xds/apiclient/grpc_envoy.go | 444 +++++++++++++++++++++
pixiu/pkg/config/xds/apiclient/grpc_test.go | 10 +-
pixiu/pkg/config/xds/cds.go | 12 +-
pixiu/pkg/config/xds/cds_test.go | 18 +-
pixiu/pkg/config/xds/lds.go | 10 +-
pixiu/pkg/config/xds/lds_test.go | 6 +-
pixiu/pkg/config/xds/xds.go | 51 ++-
pixiu/pkg/config/xds/xds_test.go | 18 +-
pixiu/pkg/model/base.go | 8 +-
pixiu/pkg/model/listener.go | 7 +-
pixiu/pkg/server/dynamic_resource_manager.go | 4 +-
18 files changed, 582 insertions(+), 103 deletions(-)
diff --git a/.gitignore b/.gitignore
index 32981e70..e283ccaa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,4 +27,5 @@ coverage.txt
target/
samples/**/dist
-out/
\ No newline at end of file
+out/
+/test
\ No newline at end of file
diff --git a/go.mod b/go.mod
index be160adb..20f9e1fc 100644
--- a/go.mod
+++ b/go.mod
@@ -23,7 +23,7 @@ require (
github.com/creasty/defaults v1.5.2
github.com/davecgh/go-spew v1.1.1
github.com/docker/cli v20.10.17+incompatible
- github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a
+ github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220612115254-d9a176b25b99
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5
github.com/dubbogo/gost v1.11.25
github.com/dubbogo/grpc-go v1.42.9
diff --git a/go.sum b/go.sum
index 41cee1a5..48def1a6 100644
--- a/go.sum
+++ b/go.sum
@@ -644,8 +644,8 @@ github.com/docker/libnetwork v0.8.0-dev.2.0.20200917202933-d0951081b35f/go.mod h
github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
-github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a h1:M4EqGQRk3jO+k50Wa9EtrOoCYlU/kXzbpYxVo4s4Wi0=
-github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a/go.mod h1:1l+6pDTdEHwCyyyJmfckOAdGp6f5PZ33ZVMgxso9q/U=
+github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220612115254-d9a176b25b99 h1:UjDxgIEu6DbJVJTrxm5mwC0j54jNao1pkYVlT8X+KgY=
+github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220612115254-d9a176b25b99/go.mod h1:1l+6pDTdEHwCyyyJmfckOAdGp6f5PZ33ZVMgxso9q/U=
github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 h1:XoR8SSVziXe698dt4uZYDfsmHpKLemqAgFyndQsq5Kw=
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
diff --git a/pixiu/pkg/adapter/dubboregistry/registry/util.go b/pixiu/pkg/adapter/dubboregistry/registry/util.go
index 8c25075f..c3e23965 100644
--- a/pixiu/pkg/adapter/dubboregistry/registry/util.go
+++ b/pixiu/pkg/adapter/dubboregistry/registry/util.go
@@ -19,7 +19,6 @@ package registry
import (
"dubbo.apache.org/dubbo-go/v3/common"
-
"github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
)
diff --git a/pixiu/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go b/pixiu/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
index 9c57179d..671e801b 100644
--- a/pixiu/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
+++ b/pixiu/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
@@ -31,9 +31,7 @@ import (
"dubbo.apache.org/dubbo-go/v3/metadata/definition"
dr "dubbo.apache.org/dubbo-go/v3/registry"
"dubbo.apache.org/dubbo-go/v3/remoting/zookeeper/curator_discovery"
-
"github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
-
"github.com/dubbogo/go-zookeeper/zk"
)
diff --git a/pixiu/pkg/config/xds/apiclient/apiclient.go b/pixiu/pkg/config/xds/apiclient/apiclient.go
index 0a68e67b..8f8c2c63 100644
--- a/pixiu/pkg/config/xds/apiclient/apiclient.go
+++ b/pixiu/pkg/config/xds/apiclient/apiclient.go
@@ -24,6 +24,8 @@ import (
import (
v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
+ anypb "github.com/golang/protobuf/ptypes/any"
+
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
@@ -35,6 +37,7 @@ type (
ProtoAny struct {
typeConfig *v3.TypedExtensionConfig
+ any *anypb.Any
}
DeltaResources struct {
@@ -48,6 +51,10 @@ func (p *ProtoAny) GetName() string {
}
func (p *ProtoAny) To(configModel PixiuDynamicConfigModel) error {
+ if p.any != nil {
+ return p.any.UnmarshalTo(configModel)
+ }
+
err := p.typeConfig.TypedConfig.UnmarshalTo(configModel)
if err != nil {
panic(err)
diff --git a/pixiu/pkg/config/xds/apiclient/grpc.go b/pixiu/pkg/config/xds/apiclient/grpc.go
index 7a490455..c0e9dad6 100644
--- a/pixiu/pkg/config/xds/apiclient/grpc.go
+++ b/pixiu/pkg/config/xds/apiclient/grpc.go
@@ -25,6 +25,10 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+
envoyconfigcorev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
extensionpb "github.com/envoyproxy/go-control-plane/envoy/service/extension/v3"
@@ -39,12 +43,6 @@ import (
"google.golang.org/protobuf/types/known/anypb"
)
-import (
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
-)
-
// agent name to talk with xDS server
const xdsAgentName = "dubbo-go-pixiu"
@@ -54,18 +52,19 @@ var (
)
type (
- GrpcApiClient struct {
+ GrpcExtensionApiClient struct {
config model.ApiConfigSource
grpcMg *GRPCClusterManager
node *model.Node
xDSExtensionClient extensionpb.ExtensionConfigDiscoveryServiceClient
resourceNames []ResourceTypeName
+ typeUrl string
exitCh chan struct{}
- xdsState xdsState
}
xdsState struct {
nonce string
deltaVersion map[string]string
+ versionInfo string
}
)
@@ -82,23 +81,23 @@ func Stop() {
}
}
-// CreateGrpcApiClient create Grpc type ApiClient
-func CreateGrpcApiClient(config *model.ApiConfigSource, node *model.Node,
+// CreateGrpExtensionApiClient create Grpc type ApiClient
+func CreateGrpExtensionApiClient(config *model.ApiConfigSource, node *model.Node,
exitCh chan struct{},
- typeNames ...ResourceTypeName) *GrpcApiClient {
- v := &GrpcApiClient{
- config: *config,
- node: node,
- resourceNames: typeNames,
- grpcMg: grpcMg,
- exitCh: exitCh,
+ typeName ResourceTypeName) *GrpcExtensionApiClient {
+ v := &GrpcExtensionApiClient{
+ config: *config,
+ node: node,
+ typeUrl: typeName,
+ grpcMg: grpcMg,
+ exitCh: exitCh,
}
v.init()
return v
}
// Fetch get config data from discovery service and return Any type.
-func (g *GrpcApiClient) Fetch(localVersion string) ([]*ProtoAny, error) {
+func (g *GrpcExtensionApiClient) Fetch(localVersion string) ([]*ProtoAny, error) {
clsRsp, err := g.xDSExtensionClient.FetchExtensionConfigs(context.Background(), &discoverypb.DiscoveryRequest{
VersionInfo: localVersion,
Node: g.makeNode(),
@@ -120,17 +119,17 @@ func (g *GrpcApiClient) Fetch(localVersion string) ([]*ProtoAny, error) {
return extensions, nil
}
-func (g *GrpcApiClient) decodeSource(resource *anypb.Any) (*ProtoAny, error) {
+func (g *GrpcExtensionApiClient) decodeSource(resource *anypb.Any) (*ProtoAny, error) {
extension := envoyconfigcorev3.TypedExtensionConfig{}
err := resource.UnmarshalTo(&extension)
if err != nil {
return nil, errors.Wrapf(err, "typed extension as expected.(%s)", g.resourceNames)
}
- elems := &ProtoAny{&extension}
+ elems := &ProtoAny{typeConfig: &extension}
return elems, nil
}
-func (g *GrpcApiClient) makeNode() *envoyconfigcorev3.Node {
+func (g *GrpcExtensionApiClient) makeNode() *envoyconfigcorev3.Node {
return &envoyconfigcorev3.Node{
Id: g.node.Id,
Cluster: g.node.Cluster,
@@ -138,21 +137,22 @@ func (g *GrpcApiClient) makeNode() *envoyconfigcorev3.Node {
}
}
-func (g *GrpcApiClient) Delta() (chan *DeltaResources, error) {
+func (g *GrpcExtensionApiClient) Delta() (chan *DeltaResources, error) {
outputCh := make(chan *DeltaResources)
return outputCh, g.runDelta(outputCh)
}
-func (g *GrpcApiClient) runDelta(output chan<- *DeltaResources) error {
+func (g *GrpcExtensionApiClient) runDelta(output chan<- *DeltaResources) error {
var delta extensionpb.ExtensionConfigDiscoveryService_DeltaExtensionConfigsClient
var cancel context.CancelFunc
+ var xState xdsState
backoff := func() {
for {
//back off
var err error
var ctx context.Context // context to sync exitCh
ctx, cancel = context.WithCancel(context.TODO())
- delta, err = g.sendInitDeltaRequest(ctx)
+ delta, err = g.sendInitDeltaRequest(ctx, &xState)
if err != nil {
logger.Error("can not receive delta discovery request, will back off 1 sec later", err)
select {
@@ -187,9 +187,9 @@ func (g *GrpcApiClient) runDelta(output chan<- *DeltaResources) error {
logger.Error("can not receive delta discovery request", err)
break
}
- g.handleDeltaResponse(resp, output)
+ g.handleDeltaResponse(resp, &xState, output)
- err = g.subscribeOnGoingChang(delta)
+ err = g.subscribeOnGoingChang(delta, &xState)
if err != nil {
logger.Error("can not recv delta discovery request", err)
break
@@ -202,10 +202,10 @@ func (g *GrpcApiClient) runDelta(output chan<- *DeltaResources) error {
return nil
}
-func (g *GrpcApiClient) handleDeltaResponse(resp *discoverypb.DeltaDiscoveryResponse, output chan<- *DeltaResources) {
+func (g *GrpcExtensionApiClient) handleDeltaResponse(resp *discoverypb.DeltaDiscoveryResponse, xState *xdsState, output chan<- *DeltaResources) {
// save the xds state
- g.xdsState.deltaVersion = make(map[string]string, 1)
- g.xdsState.nonce = resp.Nonce
+ xState.deltaVersion = make(map[string]string, 1)
+ xState.nonce = resp.Nonce
resources := &DeltaResources{
NewResources: make([]*ProtoAny, 0, 1),
@@ -219,7 +219,7 @@ func (g *GrpcApiClient) handleDeltaResponse(resp *discoverypb.DeltaDiscoveryResp
for _, res := range resp.Resources {
logger.Infof("new resource found %s version=%s", res.Name, res.Version)
- g.xdsState.deltaVersion[res.Name] = res.Version
+ xState.deltaVersion[res.Name] = res.Version
elems, err := g.decodeSource(res.Resource)
if err != nil {
logger.Infof("can not decode source %s version=%s", res.Name, res.Version, err)
@@ -230,17 +230,17 @@ func (g *GrpcApiClient) handleDeltaResponse(resp *discoverypb.DeltaDiscoveryResp
output <- resources
}
-func (g *GrpcApiClient) subscribeOnGoingChang(delta extensionpb.ExtensionConfigDiscoveryService_DeltaExtensionConfigsClient) error {
+func (g *GrpcExtensionApiClient) subscribeOnGoingChang(delta extensionpb.ExtensionConfigDiscoveryService_DeltaExtensionConfigsClient, xState *xdsState) error {
err := delta.Send(&discoverypb.DeltaDiscoveryRequest{
Node: g.makeNode(),
TypeUrl: resource.ExtensionConfigType,
- InitialResourceVersions: g.xdsState.deltaVersion,
- ResponseNonce: g.xdsState.nonce,
+ InitialResourceVersions: xState.deltaVersion,
+ ResponseNonce: xState.nonce,
})
return err
}
-func (g *GrpcApiClient) sendInitDeltaRequest(ctx context.Context) (extensionpb.ExtensionConfigDiscoveryService_DeltaExtensionConfigsClient, error) {
+func (g *GrpcExtensionApiClient) sendInitDeltaRequest(ctx context.Context, xState *xdsState) (extensionpb.ExtensionConfigDiscoveryService_DeltaExtensionConfigsClient, error) {
delta, err := g.xDSExtensionClient.DeltaExtensionConfigs(ctx)
if err != nil {
return nil, errors.Wrapf(err, "can not start delta stream with xds server ")
@@ -248,10 +248,10 @@ func (g *GrpcApiClient) sendInitDeltaRequest(ctx context.Context) (extensionpb.E
err = delta.Send(&discoverypb.DeltaDiscoveryRequest{
Node: g.makeNode(),
TypeUrl: resource.ExtensionConfigType,
- ResourceNamesSubscribe: g.resourceNames,
+ ResourceNamesSubscribe: []string{g.typeUrl},
ResourceNamesUnsubscribe: nil,
- InitialResourceVersions: g.xdsState.deltaVersion,
- ResponseNonce: g.xdsState.nonce,
+ InitialResourceVersions: xState.deltaVersion,
+ ResponseNonce: xState.nonce,
ErrorDetail: nil,
})
if err != nil {
@@ -260,7 +260,7 @@ func (g *GrpcApiClient) sendInitDeltaRequest(ctx context.Context) (extensionpb.E
return delta, nil
}
-func (g *GrpcApiClient) init() {
+func (g *GrpcExtensionApiClient) init() {
if len(g.config.ClusterName) == 0 {
panic("should config one cluster at least")
}
@@ -362,11 +362,11 @@ func (g *GRPCCluster) GetConnection() (conn *grpc.ClientConn, err error) {
grpc.WithTransportCredentials(creds),
grpc.WithBlock(),
)
- logger.Infof("connected xds server (%s)", endpoint)
if err != nil {
err = errors.Errorf("grpc.Dial(%s) failed: %v", endpoint, err)
return
}
+ logger.Infof("connected xds server (%s)", endpoint)
g.conn = conn
})
return g.conn, nil
diff --git a/pixiu/pkg/config/xds/apiclient/grpc_envoy.go b/pixiu/pkg/config/xds/apiclient/grpc_envoy.go
new file mode 100644
index 00000000..05b4d33d
--- /dev/null
+++ b/pixiu/pkg/config/xds/apiclient/grpc_envoy.go
@@ -0,0 +1,444 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package apiclient
+
+import (
+ "context"
+ "os"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/common/logger"
+
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
+ xdspb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+
+ clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
+ envoyconfigcorev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
+ endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
+ listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
+ discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
+ extensionpb "github.com/envoyproxy/go-control-plane/envoy/service/extension/v3"
+ "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
+
+ "github.com/pkg/errors"
+
+ "google.golang.org/protobuf/proto"
+
+ "google.golang.org/protobuf/types/known/anypb"
+ "google.golang.org/protobuf/types/known/structpb"
+)
+
+type GrpcApiClientOption func(*AggGrpcApiClient)
+
+func WithIstioService(serviceNames ...string) GrpcApiClientOption {
+ return func(g *AggGrpcApiClient) {
+ for _, name := range serviceNames {
+ g.dubboServiceFilter[name] = struct{}{}
+ }
+ }
+}
+
+// CreateEnvoyGrpcApiClient create Grpc type ApiClient
+func CreateEnvoyGrpcApiClient(
+ config *model.ApiConfigSource,
+ node *model.Node,
+ exitCh chan struct{},
+ typeName ResourceTypeName,
+ opts ...GrpcApiClientOption,
+) *AggGrpcApiClient {
+ v := &AggGrpcApiClient{}
+ v.config = *config
+ v.node = node
+ v.grpcMg = grpcMg
+ v.exitCh = exitCh
+ switch typeName {
+ case xds.ListenerType:
+ v.typeUrl = resource.ListenerType
+ case xds.ClusterType:
+ v.typeUrl = resource.ClusterType
+ case xds.EndpointType:
+ v.typeUrl = resource.EndpointType
+ default:
+ logger.Warnf("typeName should be dubbo-go.pixiu/v1/discovery:cluster or dubbo-go.pixiu/v1/discovery:listener")
+ v.typeUrl = resource.ClusterType
+ }
+
+ v.dubboServiceFilter = make(map[string]struct{}, 10)
+ for _, fn := range opts {
+ fn(v)
+ }
+ v.init()
+ return v
+}
+
+type (
+ AggGrpcApiClient struct {
+ GrpcExtensionApiClient
+ xDSAggClient discoverypb.AggregatedDiscoveryServiceClient
+ dubboServiceFilter map[string]struct{} // the service name to filter
+ }
+ discoveryResponseHandler func(any2 []*anypb.Any)
+)
+
+func (g *AggGrpcApiClient) init() {
+ if len(g.config.ClusterName) == 0 {
+ panic("should config one cluster at least")
+ }
+ //todo implement multiple grpc api services
+ if len(g.config.ClusterName) > 1 {
+ logger.Warn("defined multiple cluster for xDS api services but only one support.")
+ }
+ cluster, err := g.grpcMg.GetGrpcCluster(g.config.ClusterName[0])
+
+ if err != nil {
+ logger.Errorf("get cluster for init error. error=%v", err)
+ panic(err)
+ }
+ conn, err := cluster.GetConnection()
+ if err != nil {
+ panic(err)
+ }
+ g.xDSExtensionClient = extensionpb.NewExtensionConfigDiscoveryServiceClient(conn)
+ g.xDSAggClient = discoverypb.NewAggregatedDiscoveryServiceClient(conn)
+
+}
+
+func (g *AggGrpcApiClient) Fetch(_ string) ([]*ProtoAny, error) {
+ //un-support fetch
+ return nil, nil
+}
+
+func (g *AggGrpcApiClient) Delta() (chan *DeltaResources, error) {
+ outputCh := make(chan *DeltaResources)
+ return outputCh, g.pipeline(outputCh)
+}
+
+type refEndpoint struct {
+ IsPending bool
+ RawProto proto.Message
+}
+
+func (g *AggGrpcApiClient) pipeline(output chan *DeltaResources) error {
+ // all endpoint refer cluster or listener. map[type]map[resource name]endpoint info
+ edsResources := make(map[resource.Type]map[string]refEndpoint)
+ req := g.makeDiscoveryRequest(g.resourceNames, g.typeUrl)
+ var handler discoveryResponseHandler
+ switch g.typeUrl {
+ case resource.ListenerType:
+ handler = func(any2 []*anypb.Any) {
+ for _, res := range any2 {
+ l := listenerpb.Listener{}
+ if err := res.UnmarshalTo(&l); err != nil {
+ logger.Warnf("can not decode source %s , %v", res.TypeUrl, res)
+ continue
+ }
+ }
+ }
+ case resource.ClusterType:
+ handler = func(any2 []*anypb.Any) {
+ // only one goroutine handle response, no need to lock for local var.
+ for _, res := range any2 {
+ logger.Infof("new resource found %s", res.TypeUrl)
+ c := clusterpb.Cluster{}
+ if err := res.UnmarshalTo(&c); err != nil {
+ logger.Warnf("can not decode source %s , %v", res.TypeUrl, res)
+ continue
+ }
+ //needn't lock edsResources
+ g.getClusterResourceReference(&c, edsResources)
+ }
+
+ pendingResourceNames := make([]string, 0)
+ clusterRefEndpoints := edsResources[resource.ClusterType]
+ // list all pending pendingResourceNames
+ for name, b := range clusterRefEndpoints {
+ if b.IsPending {
+ pendingResourceNames = append(pendingResourceNames, name)
+ }
+ }
+
+ // do not block, watch new resource at another goroutine
+ err := g.runEndpointReferences(pendingResourceNames, func(any2 []*anypb.Any) {
+ // run on another goroutine
+ extCluster := xdspb.PixiuExtensionClusters{
+ Clusters: []*xdspb.Cluster{
+ {
+ Name: "",
+ TypeStr: xds.ClusterType,
+ Type: 0,
+ EdsClusterConfig: nil,
+ LbStr: "",
+ Lb: 0,
+ HealthChecks: nil,
+ Endpoints: make([]*xdspb.Endpoint, 0, len(any2)),
+ },
+ },
+ }
+
+ for _, one := range any2 {
+ l := endpointpb.ClusterLoadAssignment{}
+ if err := one.UnmarshalTo(&l); err != nil {
+ logger.Warnf("unmarshal error", err)
+ continue
+ }
+ c := clusterRefEndpoints[l.ClusterName].RawProto.(*clusterpb.Cluster)
+ extCluster.Clusters[0].Name = g.readServiceNameOfCluster(c)
+
+ for _, ep := range l.Endpoints {
+ address := ep.LbEndpoints[0].GetEndpoint().GetAddress().GetSocketAddress()
+ extCluster.Clusters[0].Endpoints = append(extCluster.Clusters[0].Endpoints, &xdspb.Endpoint{
+ Id: "",
+ Name: "",
+ Address: &xdspb.SocketAddress{
+ Address: address.Address,
+ Port: int64(address.GetPortValue()),
+ },
+ Metadata: nil,
+ })
+ }
+ }
+
+ //make output
+ output <- &DeltaResources{
+ NewResources: []*ProtoAny{
+ {
+ typeConfig: &envoyconfigcorev3.TypedExtensionConfig{
+ Name: "cluster", //todo cluster name
+ TypedConfig: func() *anypb.Any { //make any.Any from extCluster
+ a, err := anypb.New(&extCluster)
+ if err != nil {
+ logger.Warnf("can not make anypb.Any %v", err)
+ return nil
+ }
+ return a
+ }(),
+ },
+ },
+ },
+ RemovedResource: nil,
+ }
+ })
+ if err != nil { //todo retry
+ logger.Errorf("can not run reference request %v", err)
+ }
+ }
+
+ default:
+ return errors.Errorf("nedd listenerType of clusterType but get %s", g.typeUrl)
+ }
+
+ if err := g.runDelta(req, handler); err != nil {
+ return errors.WithMessagef(err, "start run %s failed", req.TypeUrl)
+ }
+
+ return nil
+}
+
+// readServiceNameOfCluster get service name of k8s
+func (g *AggGrpcApiClient) readServiceNameOfCluster(c *clusterpb.Cluster) string {
+ if c.Metadata == nil {
+ return ""
+ }
+ return c.
+ Metadata.
+ FilterMetadata["istio"].
+ Fields["services"].
+ GetListValue().
+ GetValues()[0].
+ GetStructValue().
+ Fields["name"].
+ GetStringValue()
+}
+
+// request EDS for the allResourceNames
+func (g *AggGrpcApiClient) runEndpointReferences(allResourceNames []string,
+ output discoveryResponseHandler) (err error) {
+
+ //todo reload all request
+ req := g.makeDiscoveryRequest(allResourceNames, resource.EndpointType)
+ if err := g.runDelta(req, output); err != nil {
+ return errors.WithMessagef(err, "start run %s failed", req.TypeUrl)
+ }
+ return nil
+}
+
+// runDelta start 2 goroutine to and watch change
+func (g *AggGrpcApiClient) runDelta(req *discoverypb.DiscoveryRequest, output discoveryResponseHandler) error {
+ var delta discoverypb.AggregatedDiscoveryService_StreamAggregatedResourcesClient
+ var cancel context.CancelFunc
+ var xState xdsState
+ //read resource list
+ backoff := func() {
+ xState = xdsState{}
+ for {
+ //back off
+ var err error
+ var ctx context.Context // context to sync exitCh
+ ctx, cancel = context.WithCancel(context.TODO())
+ delta, err = g.sendInitAggRequest(ctx, req, &xState)
+ if err != nil {
+ logger.Error("can not receive delta discovery request, will back off 1 sec later", err)
+ select {
+ case <-time.After(1 * time.Second):
+ case <-g.exitCh:
+ logger.Infof("get close single.")
+ return
+ }
+ continue //backoff
+ }
+ return //success
+ }
+ }
+
+ backoff()
+ if delta == nil { // delta instance not created because exitCh
+ return nil
+ }
+ go func() {
+ //waiting exitCh close
+ for range g.exitCh {
+ }
+ cancel()
+ }()
+ //get message
+ go func() {
+ for { // delta response backoff.
+ for { //loop consume receive data form xds server(sendInitDeltaRequest)
+ resp, err := delta.Recv()
+ if err != nil {
+ logger.Error("can not receive delta discovery request", err)
+ break
+ }
+ g.handleDeltaResponse(resp, &xState, output)
+ }
+ backoff()
+ }
+ }()
+
+ return nil
+}
+
+func (g *AggGrpcApiClient) handleDeltaResponse(resp *discoverypb.DiscoveryResponse, xdsState *xdsState, handler discoveryResponseHandler) {
+ // save the xds state
+ xdsState.deltaVersion = make(map[string]string, 1)
+ xdsState.nonce = resp.Nonce
+ xdsState.versionInfo = resp.VersionInfo
+ handler(resp.Resources)
+ //notify the resource change handler
+ //output <- resources
+}
+
+func (g *AggGrpcApiClient) sendInitAggRequest(ctx context.Context, req *discoverypb.DiscoveryRequest, xState *xdsState) (stream discoverypb.AggregatedDiscoveryService_StreamAggregatedResourcesClient, err error) {
+ req.VersionInfo = xState.versionInfo
+ req.ResponseNonce = xState.nonce
+ stream, err = g.xDSAggClient.StreamAggregatedResources(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "fetch dynamic resource from remote error. %s", g.resourceNames)
+ }
+
+ err = stream.Send(req)
+ if err != nil {
+ return nil, errors.Wrapf(err, "fetch dynamic resource from remote error. %s", g.resourceNames)
+ }
+ return
+}
+
+func (g *AggGrpcApiClient) makeDiscoveryRequest(resources []string,
+ typeUrl string,
+) *discoverypb.DiscoveryRequest {
+ return &discoverypb.DiscoveryRequest{
+ //VersionInfo: xdsState.versionInfo,
+ Node: g.makeNode(),
+ ResourceNames: resources, //[]string{"outbound|20000||dubbo-go-app.default.svc.cluster.local"},
+ TypeUrl: typeUrl, //"type.googleapis.com/envoy.config.listener.v3.Listener",
+ //ResponseNonce: xdsState.nonce,
+ ErrorDetail: nil,
+ }
+}
+
+func (g *AggGrpcApiClient) makeNode() *envoyconfigcorev3.Node {
+ podId := os.Getenv("POD_IP")
+ if len(podId) == 0 {
+ logger.Warnf("expect POD_ID env")
+ podId = "0.0.0.0"
+ }
+ podName := os.Getenv("POD_NAME")
+ if len(podName) == 0 {
+ logger.Warnf("expect POD_NAME env")
+ podName = "pixiu-gateway"
+ }
+ nsName := os.Getenv("POD_NAMESPACE")
+ if len(nsName) == 0 {
+ logger.Warnf("expect POD_NAMESPACE env")
+ nsName = "default"
+ }
+
+ return &envoyconfigcorev3.Node{
+ Id: "sidecar~" + podId + "~" + podName + "." + nsName + ".svc.cluster.local",
+ UserAgentName: "pixiu",
+ Cluster: "testCluster",
+ UserAgentVersionType: &envoyconfigcorev3.Node_UserAgentVersion{UserAgentVersion: "1.45.0"},
+ ClientFeatures: []string{"envoy.lb.does_not_support_overprovisioning"},
+ Metadata: &structpb.Struct{
+ Fields: map[string]*structpb.Value{
+ "CLUSTER_ID": {
+ Kind: &structpb.Value_StringValue{StringValue: "Kubernetes"},
+ },
+ "LABELS": {
+ Kind: &structpb.Value_StructValue{StructValue: &structpb.Struct{
+ Fields: map[string]*structpb.Value{},
+ }},
+ },
+ },
+ },
+ }
+}
+
+// getClusterResourceReference get resources of cluster
+func (g *AggGrpcApiClient) getClusterResourceReference(c *clusterpb.Cluster, edsResources map[resource.Type]map[string]refEndpoint) {
+ logger.Infof("cluster name ==>%s", c.Name)
+ if _, exist := g.dubboServiceFilter[g.readServiceNameOfCluster(c)]; !exist {
+ logger.Infof("cluster name ==>%v", c)
+ return
+ }
+
+ switch typ := c.ClusterDiscoveryType.(type) {
+ case *clusterpb.Cluster_Type:
+ if typ.Type == clusterpb.Cluster_EDS {
+ name := c.Name
+ if c.EdsClusterConfig != nil && c.EdsClusterConfig.ServiceName != "" {
+ name = c.EdsClusterConfig.ServiceName
+ }
+
+ if _, ok := edsResources[resource.ClusterType]; !ok {
+ edsResources[resource.ClusterType] = make(map[string]refEndpoint)
+ }
+
+ edsResources[resource.ClusterType][name] = refEndpoint{
+ IsPending: true,
+ RawProto: c,
+ }
+ } else {
+ logger.Infof("cluster type %s not supported", typ.Type.String())
+ }
+ }
+}
diff --git a/pixiu/pkg/config/xds/apiclient/grpc_test.go b/pixiu/pkg/config/xds/apiclient/grpc_test.go
index fe8b9c58..32d469c0 100644
--- a/pixiu/pkg/config/xds/apiclient/grpc_test.go
+++ b/pixiu/pkg/config/xds/apiclient/grpc_test.go
@@ -24,6 +24,10 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
+
"github.com/cch123/supermonkey"
"github.com/golang/mock/gomock"
@@ -34,12 +38,6 @@ import (
"google.golang.org/grpc/connectivity"
)
-import (
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
-)
-
func TestGRPCClusterManager_GetGrpcCluster(t *testing.T) {
cluster := &model.ClusterConfig{
Name: "cluster-1",
diff --git a/pixiu/pkg/config/xds/cds.go b/pixiu/pkg/config/xds/cds.go
index 514dd7da..60385588 100644
--- a/pixiu/pkg/config/xds/cds.go
+++ b/pixiu/pkg/config/xds/cds.go
@@ -17,18 +17,16 @@
package xds
-import (
- "github.com/dubbo-go-pixiu/pixiu-api/pkg/api"
- xdspb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
-
- "github.com/pkg/errors"
-)
-
import (
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api"
+ xdspb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+
+ "github.com/pkg/errors"
)
type CdsManager struct {
diff --git a/pixiu/pkg/config/xds/cds_test.go b/pixiu/pkg/config/xds/cds_test.go
index 8b1854c0..a1040e5b 100644
--- a/pixiu/pkg/config/xds/cds_test.go
+++ b/pixiu/pkg/config/xds/cds_test.go
@@ -23,6 +23,11 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
+
"github.com/cch123/supermonkey"
"github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
@@ -37,13 +42,6 @@ import (
"google.golang.org/protobuf/types/known/anypb"
)
-import (
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
-)
-
func makeClusters() *pixiupb.PixiuExtensionClusters {
return &pixiupb.PixiuExtensionClusters{
Clusters: []*pixiupb.Cluster{
@@ -99,7 +97,7 @@ func TestCdsManager_Fetch(t *testing.T) {
clusterMg := mocks.NewMockClusterManager(ctrl)
//var deltaResult chan *apiclient.DeltaResources
//var deltaErr error
- supermonkey.Patch((*apiclient.GrpcApiClient).Fetch, func(_ *apiclient.GrpcApiClient, localVersion string) ([]*apiclient.ProtoAny, error) {
+ supermonkey.Patch((*apiclient.GrpcExtensionApiClient).Fetch, func(_ *apiclient.GrpcExtensionApiClient, localVersion string) ([]*apiclient.ProtoAny, error) {
return fetchResult, fetchError
})
//supermonkey.Patch(server.GetClusterManager, func() *server.ClusterManager {
@@ -138,7 +136,7 @@ func TestCdsManager_Fetch(t *testing.T) {
//supermonkey.Patch((*server.ClusterManager).CloneStore, func(_ *server.ClusterManager) (*server.ClusterStore, error) {
// return &server.ClusterStore{}, nil
//})
- //supermonkey.Patch((*apiclient.GrpcApiClient).Delta, func(_ *apiclient.GrpcApiClient) (chan *apiclient.DeltaResources, error) {
+ //supermonkey.Patch((*apiclient.GrpcExtensionApiClient).Delta, func(_ *apiclient.GrpcExtensionApiClient) (chan *apiclient.DeltaResources, error) {
// return deltaResult, deltaErr
//})
defer supermonkey.UnpatchAll()
@@ -162,7 +160,7 @@ func TestCdsManager_Fetch(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &CdsManager{
- DiscoverApi: &apiclient.GrpcApiClient{},
+ DiscoverApi: &apiclient.GrpcExtensionApiClient{},
clusterMg: clusterMg,
}
//reset context value.
diff --git a/pixiu/pkg/config/xds/lds.go b/pixiu/pkg/config/xds/lds.go
index 87a82845..88c69ef2 100644
--- a/pixiu/pkg/config/xds/lds.go
+++ b/pixiu/pkg/config/xds/lds.go
@@ -22,17 +22,15 @@ import (
"strconv"
)
-import (
- xdsModel "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
-
- "gopkg.in/yaml.v2"
-)
-
import (
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+
+ xdsModel "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+
+ "gopkg.in/yaml.v2"
)
type LdsManager struct {
diff --git a/pixiu/pkg/config/xds/lds_test.go b/pixiu/pkg/config/xds/lds_test.go
index 5348cb6f..b8c82505 100644
--- a/pixiu/pkg/config/xds/lds_test.go
+++ b/pixiu/pkg/config/xds/lds_test.go
@@ -22,6 +22,8 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+
pixiupb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
"github.com/stretchr/testify/assert"
@@ -32,10 +34,6 @@ import (
structpb2 "google.golang.org/protobuf/types/known/structpb"
)
-import (
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
-)
-
func TestLdsManager_makeConfig(t *testing.T) {
var httpManagerConfigYaml = `
route_config:
diff --git a/pixiu/pkg/config/xds/xds.go b/pixiu/pkg/config/xds/xds.go
index 38912064..ed21f287 100644
--- a/pixiu/pkg/config/xds/xds.go
+++ b/pixiu/pkg/config/xds/xds.go
@@ -22,14 +22,15 @@ import (
)
import (
- "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
-)
-
-import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/common/constant"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
"github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
+
+ "github.com/mitchellh/mapstructure"
)
type (
@@ -54,20 +55,58 @@ type (
func (a *Xds) createApiManager(config *model.ApiConfigSource,
node *model.Node,
- resourceTypes ...apiclient.ResourceTypeName) DiscoverApi {
+ resourceType apiclient.ResourceTypeName) DiscoverApi {
if config == nil {
return nil
}
switch config.APIType {
case model.ApiTypeGRPC:
- return apiclient.CreateGrpcApiClient(config, node, a.exitCh, resourceTypes...)
+ return apiclient.CreateGrpExtensionApiClient(config, node, a.exitCh, resourceType)
+ case model.ApiTypeIstioGRPC:
+ dubboServices, err := a.readDubboServiceFromListener()
+ if err != nil {
+ logger.Errorf("can not read listener. %v", err)
+ return nil
+ }
+ return apiclient.CreateEnvoyGrpcApiClient(config, node, a.exitCh, resourceType, apiclient.WithIstioService(dubboServices...))
default:
logger.Errorf("un-support the api type %s", config.APITypeStr)
return nil
}
}
+func (a *Xds) readDubboServiceFromListener() ([]string, error) {
+ dubboServices := make([]string, 0)
+ listeners, err := a.listenerMg.CloneXdsControlListener()
+ if err != nil {
+ return nil, err
+ }
+
+ for _, l := range listeners {
+ for _, filter := range l.FilterChain.Filters {
+ if filter.Name != constant.HTTPConnectManagerFilter {
+ continue
+ }
+ var cfg *model.HttpConnectionManagerConfig
+ if filter.Config != nil {
+ if err := mapstructure.Decode(filter.Config, &cfg); err != nil {
+ logger.Error("read listener config error when init xds", err)
+ continue
+ }
+ }
+ for _, httpFilter := range cfg.HTTPFilters {
+ if httpFilter.Name == constant.HTTPDirectDubboProxyFilter {
+ for _, route := range cfg.RouteConfig.Routes {
+ dubboServices = append(dubboServices, route.Route.Cluster)
+ }
+ }
+ }
+ }
+ }
+ return dubboServices, nil
+}
+
func (a *Xds) Start() {
if a.dynamicResourceMg == nil { // if dm is nil, then config not initialized.
logger.Infof("can not get dynamic resource manager. maybe the config has not initialized")
diff --git a/pixiu/pkg/config/xds/xds_test.go b/pixiu/pkg/config/xds/xds_test.go
index 1876354e..aaea0ca6 100644
--- a/pixiu/pkg/config/xds/xds_test.go
+++ b/pixiu/pkg/config/xds/xds_test.go
@@ -24,6 +24,12 @@ import (
)
import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
+ _ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
+
monkey "github.com/cch123/supermonkey"
"github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
@@ -36,14 +42,6 @@ import (
"google.golang.org/grpc/connectivity"
)
-import (
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
- _ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/config/xds/apiclient"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls"
- "github.com/apache/dubbo-go-pixiu/pixiu/pkg/server/controls/mocks"
-)
-
func TestAdapter_createApiManager(t *testing.T) {
cluster := &model.ClusterConfig{
Name: "cluster-1",
@@ -100,10 +98,10 @@ func TestAdapter_createApiManager(t *testing.T) {
// }, nil
//})
- monkey.Patch((*apiclient.GrpcApiClient).Fetch, func(_ *apiclient.GrpcApiClient, localVersion string) ([]*apiclient.ProtoAny, error) {
+ monkey.Patch((*apiclient.GrpcExtensionApiClient).Fetch, func(_ *apiclient.GrpcExtensionApiClient, localVersion string) ([]*apiclient.ProtoAny, error) {
return nil, nil
})
- monkey.Patch((*apiclient.GrpcApiClient).Delta, func(_ *apiclient.GrpcApiClient) (chan *apiclient.DeltaResources, error) {
+ monkey.Patch((*apiclient.GrpcExtensionApiClient).Delta, func(_ *apiclient.GrpcExtensionApiClient) (chan *apiclient.DeltaResources, error) {
ch := make(chan *apiclient.DeltaResources)
close(ch)
return ch, nil
diff --git a/pixiu/pkg/model/base.go b/pixiu/pkg/model/base.go
index 486fd00a..79447f31 100644
--- a/pixiu/pkg/model/base.go
+++ b/pixiu/pkg/model/base.go
@@ -45,6 +45,7 @@ const (
ApiTypeREST api.ApiType = 0 + iota // support for 1.0
ApiTypeGRPC
ApiTypeDUBBO
+ ApiTypeIstioGRPC
)
var (
@@ -67,9 +68,10 @@ var (
}
ApiTypeValue = map[string]int32{
- REST_VALUE: 0,
- GRPC_VALUE: 1,
- DUBBO_VALUE: 2,
+ REST_VALUE: 0,
+ GRPC_VALUE: 1,
+ DUBBO_VALUE: 2,
+ ISTIOGRPC_VALUE: 3,
}
)
diff --git a/pixiu/pkg/model/listener.go b/pixiu/pkg/model/listener.go
index ea1e2fd7..c458859a 100644
--- a/pixiu/pkg/model/listener.go
+++ b/pixiu/pkg/model/listener.go
@@ -28,9 +28,10 @@ const (
)
const (
- REST_VALUE = "REST"
- GRPC_VALUE = "GRPC"
- DUBBO_VALUE = "DUBBO"
+ REST_VALUE = "REST"
+ GRPC_VALUE = "GRPC"
+ DUBBO_VALUE = "DUBBO"
+ ISTIOGRPC_VALUE = "ISTIO"
)
var (
diff --git a/pixiu/pkg/server/dynamic_resource_manager.go b/pixiu/pkg/server/dynamic_resource_manager.go
index 739e15a0..dc545261 100644
--- a/pixiu/pkg/server/dynamic_resource_manager.go
+++ b/pixiu/pkg/server/dynamic_resource_manager.go
@@ -100,8 +100,8 @@ func convertApiType(config *model.ApiConfigSource) error {
return errors.Errorf("unknown apiType %s", config.APITypeStr)
}
config.APIType = api.ApiType(apiType)
- if config.APIType != model.ApiTypeGRPC {
- return errors.Errorf("APIType support GRPC only but get %s", config.APITypeStr)
+ if config.APIType != model.ApiTypeGRPC && config.APIType != model.ApiTypeIstioGRPC {
+ return errors.Errorf("APIType support GRPC/ISTIO only but get %s", config.APITypeStr)
}
}
return nil