Skip to content

Commit

Permalink
use kuberesolver for kubernetes service endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Jul 17, 2024
1 parent 23a9fe5 commit 13c88ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/respect-service-transport.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Enhancement: Respect service transport

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).
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).

https://github.com/cs3org/reva/pull/4744
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ require (
github.com/rs/cors v1.10.1
github.com/rs/zerolog v1.32.0
github.com/segmentio/kafka-go v0.4.47
github.com/sercand/kuberesolver/v5 v5.1.1
github.com/sethvargo/go-password v0.2.0
github.com/shamaton/msgpack/v2 v2.1.1
github.com/shirou/gopsutil v3.21.11+incompatible
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUt
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUanQQB0=
github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg=
github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY=
github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
Expand Down
9 changes: 8 additions & 1 deletion pkg/rgrpc/todo/pool/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ import (
tx "github.com/cs3org/go-cs3apis/cs3/tx/v1beta1"
"github.com/cs3org/reva/v2/pkg/registry"
"github.com/pkg/errors"
"github.com/sercand/kuberesolver/v5"
"google.golang.org/grpc"
)

func init() {
// grpc go resolver.Register must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe.
kuberesolver.RegisterInCluster()
}

type Selectable[T any] interface {
Next(opts ...Option) (T, error)
}
Expand Down Expand Up @@ -97,7 +104,7 @@ func (s *Selector[T]) Next(opts ...Option) (T, error) {
target := s.id
prefix := strings.SplitN(s.id, ":", 2)[0]
switch prefix {
case "dns", "unix":
case "dns", "unix", "kubernetes":
// use target as is
default:
// use service registry to look up address
Expand Down

0 comments on commit 13c88ef

Please sign in to comment.