Skip to content

Commit 9259197

Browse files
[feat]: Introduce multi-cluster and multi-registry architecture (#795)
* [feat]: add support of multicluster * [chore]: add unit tests * [feat]: implement kubernetes native service discovery for dubbo services * [chore]: add comprehensive k8s service discovery capabilities * feat: implement Istio as service registry and runtime platform - Add comprehensive Istio service mesh integration for service discovery - Implement Istio service registry controller with xDS protocol support - Add gRPC client for Istio Pilot communication and service watching - Extend service model with Istio-specific fields (VirtualService, DestinationRule) - Support service conversion between Istio and Dubbo formats - Add configuration management with TLS support - Integrate Istio provider into aggregated service registry - Include command-line flags for Istio configuration - Add comprehensive test coverage and documentation - Provide Kubernetes deployment examples and usage guides * [chore]: fix a series of bugs, add ASF headers * [chore]: format code, add missing ASF headers
1 parent 49e4c52 commit 9259197

File tree

96 files changed

+6036
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+6036
-42
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Istio Service Registry Configuration Example
19+
# This example demonstrates how to configure Dubbo-Kubernetes to use Istio as a service registry
20+
21+
apiVersion: v1
22+
kind: ConfigMap
23+
metadata:
24+
name: dubbo-istio-config
25+
namespace: dubbo-system
26+
data:
27+
# Istio Pilot configuration
28+
istio.pilot.address: "istiod.istio-system.svc.cluster.local:15010"
29+
istio.namespace: "istio-system"
30+
istio.tls.enabled: "true"
31+
istio.sync.timeout: "30s"
32+
33+
# Service discovery configuration
34+
istio.enable.discovery: "true"
35+
istio.service.name: "dubbo-control-plane"
36+
istio.service.version: "v1"
37+
38+
# TLS certificate paths (optional, for mTLS)
39+
# istio.cert.path: "/etc/certs/cert.pem"
40+
# istio.key.path: "/etc/certs/key.pem"
41+
# istio.ca.path: "/etc/certs/ca.pem"
42+
43+
---
44+
# Deployment example for Dubbo Sail Discovery with Istio
45+
apiVersion: apps/v1
46+
kind: Deployment
47+
metadata:
48+
name: dubbo-sail-discovery
49+
namespace: dubbo-system
50+
spec:
51+
replicas: 1
52+
selector:
53+
matchLabels:
54+
app: dubbo-sail-discovery
55+
template:
56+
metadata:
57+
labels:
58+
app: dubbo-sail-discovery
59+
annotations:
60+
sidecar.istio.io/inject: "true"
61+
spec:
62+
containers:
63+
- name: discovery
64+
image: dubbo/sail-discovery:latest
65+
args:
66+
- --registries=Istio
67+
- --istio-pilot-address=istiod.istio-system.svc.cluster.local:15010
68+
- --istio-namespace=istio-system
69+
- --istio-tls-enabled=true
70+
- --istio-service-name=dubbo-control-plane
71+
- --istio-service-version=v1
72+
ports:
73+
- containerPort: 18000
74+
name: grpc
75+
- containerPort: 8080
76+
name: http
77+
env:
78+
- name: PILOT_ADDRESS
79+
value: "istiod.istio-system.svc.cluster.local:15010"
80+
- name: ISTIO_NAMESPACE
81+
value: "istio-system"
82+
- name: TLS_ENABLED
83+
value: "true"
84+
volumeMounts:
85+
- name: config
86+
mountPath: /etc/dubbo
87+
- name: certs
88+
mountPath: /etc/certs
89+
readOnly: true
90+
volumes:
91+
- name: config
92+
configMap:
93+
name: dubbo-istio-config
94+
- name: certs
95+
secret:
96+
secretName: dubbo-istio-certs
97+
optional: true
98+
99+
---
100+
# Service for Dubbo Sail Discovery
101+
apiVersion: v1
102+
kind: Service
103+
metadata:
104+
name: dubbo-sail-discovery
105+
namespace: dubbo-system
106+
labels:
107+
app: dubbo-sail-discovery
108+
spec:
109+
selector:
110+
app: dubbo-sail-discovery
111+
ports:
112+
- name: grpc
113+
port: 18000
114+
targetPort: 18000
115+
protocol: TCP
116+
- name: http
117+
port: 8080
118+
targetPort: 8080
119+
protocol: TCP
120+
121+
---
122+
# Optional: ServiceMonitor for Prometheus monitoring
123+
apiVersion: monitoring.coreos.com/v1
124+
kind: ServiceMonitor
125+
metadata:
126+
name: dubbo-sail-discovery
127+
namespace: dubbo-system
128+
spec:
129+
selector:
130+
matchLabels:
131+
app: dubbo-sail-discovery
132+
endpoints:
133+
- port: http
134+
path: /metrics
135+
interval: 30s

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ require (
5151
github.com/sashabaranov/go-openai v1.40.5
5252
github.com/spf13/cobra v1.9.1
5353
github.com/spf13/pflag v1.0.7
54+
github.com/stretchr/testify v1.10.0
5455
github.com/tmc/langchaingo v0.1.13
5556
go.uber.org/atomic v1.11.0
5657
golang.org/x/crypto v0.41.0
5758
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6
5859
golang.org/x/net v0.43.0
5960
golang.org/x/sys v0.35.0
6061
golang.org/x/term v0.34.0
62+
golang.org/x/time v0.12.0
6163
google.golang.org/grpc v1.74.2
6264
google.golang.org/protobuf v1.36.7
6365
gopkg.in/yaml.v3 v3.0.1
@@ -206,6 +208,7 @@ require (
206208
github.com/pjbgf/sha1cd v0.3.0 // indirect
207209
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
208210
github.com/planetscale/vtprotobuf v0.6.1-0.20240409071808-615f978279ca // indirect
211+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
209212
github.com/prometheus/client_golang v1.23.0 // indirect
210213
github.com/prometheus/client_model v0.6.2 // indirect
211214
github.com/prometheus/common v0.65.0 // indirect
@@ -239,7 +242,6 @@ require (
239242
golang.org/x/oauth2 v0.30.0 // indirect
240243
golang.org/x/sync v0.16.0 // indirect
241244
golang.org/x/text v0.28.0 // indirect
242-
golang.org/x/time v0.12.0 // indirect
243245
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect
244246
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect
245247
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
@@ -264,5 +266,4 @@ replace (
264266
github.com/google/go-containerregistry => github.com/google/go-containerregistry v0.20.2
265267
github.com/moby/buildkit => github.com/moby/buildkit v0.10.6
266268
github.com/moby/dockerfile => github.com/moby/dockerfile v1.4.1
267-
268269
)

manifests/charts/admin/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _internal_default_values_not_set:
3434
memory: "512Mi"
3535

3636
# Support multi deploy status, see https://github.com/apache/dubbo-kubernetes/blob/master/README.md
37-
# Available options: k8s(not supported yet), half, universal
37+
# Available options: k8s, half, universal
3838
deployMode: half
3939

4040
# Support multi-cluster
@@ -53,3 +53,9 @@ _internal_default_values_not_set:
5353
grafanaAddress: http://grafana.dubbo-system:3000
5454

5555
prometheusAddress: http://prometheus.dubbo-system:9090
56+
57+
# k8s Service discovery configuration
58+
k8sServiceDiscovery:
59+
enabled: true
60+
namespaces: ["default", "dubbo-system"]
61+
annotationPrefix: "dubbo.apache.org"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
# inject grpc template

pkg/adsc/adsc.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package adsc
219

320
import (
421
"context"
522
"crypto/tls"
623
"crypto/x509"
724
"fmt"
25+
"math"
26+
"net"
27+
"os"
28+
"strings"
29+
"sync"
30+
"time"
31+
832
"github.com/apache/dubbo-kubernetes/pkg/backoff"
933
"github.com/apache/dubbo-kubernetes/pkg/config"
1034
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collections"
@@ -30,12 +54,6 @@ import (
3054
mcp "istio.io/api/mcp/v1alpha1"
3155
"istio.io/api/mesh/v1alpha1"
3256
"k8s.io/klog/v2"
33-
"math"
34-
"net"
35-
"os"
36-
"strings"
37-
"sync"
38-
"time"
3957
)
4058

4159
const (
@@ -756,7 +774,11 @@ func (a *ADSC) handleLDS(ll []*listener.Listener) {
756774
routes = append(routes, fmt.Sprintf("%d", port))
757775
}
758776
default:
759-
klog.Infof(protomarshal.ToJSONWithIndent(l, " "))
777+
if jsonStr, err := protomarshal.ToJSONWithIndent(l, " "); err == nil {
778+
klog.Infof("Listener config: %s", jsonStr)
779+
} else {
780+
klog.Errorf("Failed to marshal to JSON: %v", err)
781+
}
760782
}
761783
}
762784

pkg/adsc/util.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package adsc
219

320
import (

pkg/bootstrap/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package bootstrap
219

320
import (

0 commit comments

Comments
 (0)