Skip to content

Commit

Permalink
set grpc client keep alive timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vramk23 committed Mar 2, 2024
1 parent fc56a33 commit d00e18d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion capten/common-pkg/vault-cred/vault_cred_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package vaultcred
import (
"context"
"fmt"
"time"

"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/timeout"
"github.com/kelseyhightower/envconfig"
managedcluster "github.com/kube-tarian/kad/capten/common-pkg/managed-cluster"
"github.com/kube-tarian/kad/capten/common-pkg/vault-cred/vaultcredpb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
v1 "k8s.io/api/core/v1"
)

Expand All @@ -22,7 +25,13 @@ func GetAppRoleToken(appRoleName string, credentialPaths []string) (string, erro
return "", fmt.Errorf("vault cred config read failed, %v", err)
}

vc, err := grpc.Dial(conf.VaultCredAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
vc, err := grpc.Dial(conf.VaultCredAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(timeout.UnaryClientInterceptor(60*time.Second)),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 30, // seconds
Timeout: 10, // seconds
}))
if err != nil {
return "", fmt.Errorf("failed to connect vauld-cred server, %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions charts/kad/templates/deployment-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ spec:
value: "{{ .Values.temporal.temporalServiceURL }}.{{ .Release.Namespace }}.svc.cluster.local:7233"
- name: PORT
value: "{{ .Values.service.port }}"
- name: HOME
value: /tmp
- name: CASSANDRA_SERVICE_URL
value: "{{ .Values.cassandra.serviceURL }}"
- name: CASSANDRA_KEYSPACE_NAME
Expand Down
6 changes: 6 additions & 0 deletions server/pkg/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -78,6 +79,11 @@ func getConnection(cfg *Config, oryClient oryclient.OryClient) (*grpc.ClientConn

dialOptions := []grpc.DialOption{
grpc.WithUnaryInterceptor(timeout.UnaryClientInterceptor(60 * time.Second)),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 30, // seconds
Timeout: 10, // seconds
PermitWithoutStream: true,
}),
}

if cfg.AuthEnabled {
Expand Down

0 comments on commit d00e18d

Please sign in to comment.