Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Add support for configuring gRPC max-connection-age for the kiam serv…
Browse files Browse the repository at this point in the history
…er (#440)

* Add support for configuring gRPC server parameters for the kiam server.
  • Loading branch information
stefansedich authored Nov 18, 2020
1 parent a9039fe commit c45a54d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/kiam/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func (o *serverOptions) bind(parser parser) {
parser.Flag("session-refresh", "How soon STS Tokens should be refreshed before their expiration.").Default("5m").DurationVar(&o.SessionRefresh)
parser.Flag("assume-role-arn", "IAM Role to assume before processing requests").Default("").StringVar(&o.AssumeRoleArn)
parser.Flag("region", "AWS Region to use for regional STS calls (e.g. us-west-2). Defaults to the global endpoint.").Default("").StringVar(&o.Region)
parser.Flag("grpc-keepalive-time-duration", "gRPC keepalive time").Default("10s").DurationVar(&o.KeepaliveParams.Time)
parser.Flag("grpc-keepalive-timeout-duration", "gRPC keepalive timeout").Default("2s").DurationVar(&o.KeepaliveParams.Timeout)
parser.Flag("grpc-max-connection-idle-duration", "gRPC max connection idle").Default("15m").DurationVar(&o.KeepaliveParams.MaxConnectionIdle)
parser.Flag("grpc-max-connection-age-duration", "gRPC max connection age").Default("15m").DurationVar(&o.KeepaliveParams.MaxConnectionAge)
parser.Flag("grpc-max-connection-age-grace-duration", "gRPC max connection age grace").Default("15m").DurationVar(&o.KeepaliveParams.MaxConnectionAgeGrace)
}

func (cmd *serverCommand) Run() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/uswitch/kiam/pkg/prefetch"
pb "github.com/uswitch/kiam/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
Expand All @@ -48,6 +49,7 @@ type Config struct {
PrefetchBufferSize int
AssumeRoleArn string
Region string
KeepaliveParams keepalive.ServerParameters
}

// TLSConfig controls TLS
Expand Down
1 change: 1 addition & 0 deletions pkg/server/server_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (b *KiamServerBuilder) WithTLS() (*KiamServerBuilder, error) {
grpc.Creds(b.transportCredentials),
grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
grpc.KeepaliveParams(b.config.KeepaliveParams),
)

return b, nil
Expand Down

0 comments on commit c45a54d

Please sign in to comment.