From a2a50b336311742bed7925dadcc1f005a91168b3 Mon Sep 17 00:00:00 2001 From: Ihor Vovk Date: Wed, 8 Jan 2025 05:26:34 +0100 Subject: [PATCH 1/2] Add GRPC reflection service --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 8b416e8..b105988 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/health" "google.golang.org/grpc/health/grpc_health_v1" + reflectionservice "google.golang.org/grpc/reflection" "k8s.io/client-go/kubernetes" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" "k8s.io/client-go/rest" @@ -76,6 +77,7 @@ func main() { }() grpc_health_v1.RegisterHealthServer(grpcServer, healthServer) + reflectionservice.Register(grpcServer) discoverygrpc.RegisterAggregatedDiscoveryServiceServer(grpcServer, xdsServer) endpointservice.RegisterEndpointDiscoveryServiceServer(grpcServer, xdsServer) clusterservice.RegisterClusterDiscoveryServiceServer(grpcServer, xdsServer) From c8a98f2f2c689ed5a144f2a2e42b44177f149dbf Mon Sep 17 00:00:00 2001 From: Ihor Vovk Date: Wed, 22 Jan 2025 21:49:35 +0100 Subject: [PATCH 2/2] Enable reflection service based on env variable --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b105988..83a89b4 100644 --- a/main.go +++ b/main.go @@ -77,13 +77,15 @@ func main() { }() grpc_health_v1.RegisterHealthServer(grpcServer, healthServer) - reflectionservice.Register(grpcServer) discoverygrpc.RegisterAggregatedDiscoveryServiceServer(grpcServer, xdsServer) endpointservice.RegisterEndpointDiscoveryServiceServer(grpcServer, xdsServer) clusterservice.RegisterClusterDiscoveryServiceServer(grpcServer, xdsServer) routeservice.RegisterRouteDiscoveryServiceServer(grpcServer, xdsServer) listenerservice.RegisterListenerDiscoveryServiceServer(grpcServer, xdsServer) loadreportingservice.RegisterLoadReportingServiceServer(grpcServer, report.NewServer(report.WithStatsIntervalInSeconds(statsIntervalInSeconds))) + if os.Getenv("ENABLE_GRPC_REFLECTION") == "true" { + reflectionservice.Register(grpcServer) + } lis, err := net.Listen("tcp", ":5000") //nolint:gosec if err != nil {