Skip to content

Commit

Permalink
add server reflection (flyteorg#34)
Browse files Browse the repository at this point in the history
The same as flyteorg/datacatalog#19

With [server reflection](https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md), it would be easier to interact with GRPC service using e.g. `grpcurl`.

flyteadmin does come with HTTP endpoint as well, but interacting with GRPC directly makes it more handy.
  • Loading branch information
honnix authored and wild-endeavor committed Nov 25, 2019
1 parent 0134a1b commit 2bedf17
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmd/entrypoints/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/lyft/flytestdlib/contextutils"
"github.com/lyft/flytestdlib/promutils/labeled"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)

// serveCmd represents the serve command
Expand Down Expand Up @@ -84,6 +85,9 @@ func newGRPCServer(ctx context.Context, cfg *config.ServerConfig, authContext in
grpcServer := grpc.NewServer(serverOpts...)
grpc_prometheus.Register(grpcServer)
flyteService.RegisterAdminServiceServer(grpcServer, adminservice.NewAdminServer(cfg.KubeConfig, cfg.Master))
if cfg.GrpcServerReflection {
reflection.Register(grpcServer)
}
return grpcServer, nil
}

Expand Down
1 change: 1 addition & 0 deletions flyteadmin_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
server:
httpPort: 8088
grpcPort: 8089
grpcServerReflection: true
security:
secure: false
ssl:
Expand Down
11 changes: 6 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ const SectionKey = "server"
//go:generate pflags ServerConfig --default-var=defaultServerConfig

type ServerConfig struct {
HTTPPort int `json:"httpPort" pflag:",On which http port to serve admin"`
GrpcPort int `json:"grpcPort" pflag:",On which grpc port to serve admin"`
KubeConfig string `json:"kube-config" pflag:",Path to kubernetes client config file."`
Master string `json:"master" pflag:",The address of the Kubernetes API server."`
Security ServerSecurityOptions `json:"security"`
HTTPPort int `json:"httpPort" pflag:",On which http port to serve admin"`
GrpcPort int `json:"grpcPort" pflag:",On which grpc port to serve admin"`
GrpcServerReflection bool `json:"grpcServerReflection" pflag:",Enable GRPC Server Reflection"`
KubeConfig string `json:"kube-config" pflag:",Path to kubernetes client config file."`
Master string `json:"master" pflag:",The address of the Kubernetes API server."`
Security ServerSecurityOptions `json:"security"`
}

type ServerSecurityOptions struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/serverconfig_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/config/serverconfig_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bedf17

Please sign in to comment.