Skip to content

Commit

Permalink
Merge pull request #413 from kube-tarian/grpc-keepalive
Browse files Browse the repository at this point in the history
set grpc client keep alive timeout
  • Loading branch information
vramk23 committed Mar 2, 2024
2 parents fc56a33 + b2b0e12 commit b513bad
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
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
1 change: 1 addition & 0 deletions capten/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/gogo/status v1.1.1
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/google/uuid v1.3.1
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0
github.com/hashicorp/go-multierror v1.1.1
github.com/intelops/go-common v1.0.22
github.com/kelseyhightower/envconfig v1.4.0
Expand Down
2 changes: 2 additions & 0 deletions capten/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0 h1:2cz5kSrxzMYHiWOBbKj8itQm+nRykkB8aMv4ThcHYHA=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
Expand Down
4 changes: 2 additions & 2 deletions charts/kad/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.15
version: 0.2.16

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.25.0"
appVersion: "1.25.1"
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
4 changes: 2 additions & 2 deletions charts/server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.26
version: 0.1.27

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.26.0"
appVersion: "1.26.1"
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 b513bad

Please sign in to comment.