Skip to content

Commit 13c88ef

Browse files
committed
use kuberesolver for kubernetes service endpoints
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
1 parent 23a9fe5 commit 13c88ef

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Enhancement: Respect service transport
22

3-
The service registry now takes into account the service transport when creating grpc clients. This allows using `dns` and `unix` as the protocol in addition to `tcp`. `dns` will turn the gRPC client into a [Thick Client](https://grpc.io/blog/grpc-load-balancing/#thick-client) that can look up multiple endpoints via DNS. Furthermore, we enabled round robin load balancing for the [default transparent retry configuration of gRPC](https://grpc.io/docs/guides/retry/#retry-configuration).
3+
The service registry now takes into account the service transport when creating grpc clients. This allows using `dns`, `unix` and `kubernetes` as the protocol in addition to `tcp`. `dns` will turn the gRPC client into a [Thick Client](https://grpc.io/blog/grpc-load-balancing/#thick-client) that can look up multiple endpoints via DNS. `kubernetes` will use [github.com/sercand/kuberesolver](https://github.com/sercand/kuberesolver) to connect to the kubernetes API and pickh up service changes. Furthermore, we enabled round robin load balancing for the [default transparent retry configuration of gRPC](https://grpc.io/docs/guides/retry/#retry-configuration).
44

55
https://github.com/cs3org/reva/pull/4744

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ require (
7171
github.com/rs/cors v1.10.1
7272
github.com/rs/zerolog v1.32.0
7373
github.com/segmentio/kafka-go v0.4.47
74+
github.com/sercand/kuberesolver/v5 v5.1.1
7475
github.com/sethvargo/go-password v0.2.0
7576
github.com/shamaton/msgpack/v2 v2.1.1
7677
github.com/shirou/gopsutil v3.21.11+incompatible

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUt
15661566
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
15671567
github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUanQQB0=
15681568
github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg=
1569+
github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY=
1570+
github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ=
15691571
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
15701572
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
15711573
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=

pkg/rgrpc/todo/pool/selector.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ import (
4444
tx "github.com/cs3org/go-cs3apis/cs3/tx/v1beta1"
4545
"github.com/cs3org/reva/v2/pkg/registry"
4646
"github.com/pkg/errors"
47+
"github.com/sercand/kuberesolver/v5"
4748
"google.golang.org/grpc"
4849
)
4950

51+
func init() {
52+
// grpc go resolver.Register must only be called during initialization time (i.e. in
53+
// an init() function), and is not thread-safe.
54+
kuberesolver.RegisterInCluster()
55+
}
56+
5057
type Selectable[T any] interface {
5158
Next(opts ...Option) (T, error)
5259
}
@@ -97,7 +104,7 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) {
97104
target := s.id
98105
prefix := strings.SplitN(s.id, ":", 2)[0]
99106
switch prefix {
100-
case "dns", "unix":
107+
case "dns", "unix", "kubernetes":
101108
// use target as is
102109
default:
103110
// use service registry to look up address

0 commit comments

Comments
 (0)