Skip to content

Commit

Permalink
add tls configs for grpc client connection
Browse files Browse the repository at this point in the history
Signed-off-by: alex60217101990 <[email protected]>

Signed-off-by: Daniel Yavorovych <[email protected]>
  • Loading branch information
Aleksandr Yershov authored and daniel-yavorovich committed Dec 29, 2021
1 parent e846b29 commit 4cc3f77
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/scalers/predictkube_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scalers

import (
"context"
"crypto/tls"
"errors"
"fmt"
"math"
Expand All @@ -14,13 +15,14 @@ import (
tc "github.com/dysnix/predictkube-libs/external/types_convertation"
"github.com/dysnix/predictkube-proto/external/proto/commonproto"
pb "github.com/dysnix/predictkube-proto/external/proto/services"
validator "github.com/go-playground/validator/v10"
"github.com/go-playground/validator/v10"
kedautil "github.com/kedacore/keda/v2/pkg/util"
"github.com/prometheus/client_golang/api"
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
"github.com/prometheus/common/model"
str2duration "github.com/xhit/go-str2duration/v2"
"github.com/xhit/go-str2duration/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
health "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
"k8s.io/api/autoscaling/v2beta2"
Expand All @@ -36,8 +38,8 @@ const (
)

var (
mlEngineHost = "predictkube-dev.dysnix.org"
mlEnginePort = 8080
mlEngineHost = "api.predictkube.com"
mlEnginePort = 443

defaultStep = time.Minute * 5
)
Expand Down Expand Up @@ -79,7 +81,7 @@ func (pks *PredictKubeScaler) setupClientConn() error {
ReadBufferSize: 50 << 20,
WriteBufferSize: 50 << 20,
MaxMessageSize: 50 << 20,
Insecure: true,
Insecure: false,
Timeout: time.Second * 15,
},
Keepalive: &libs.Keepalive{
Expand All @@ -106,6 +108,12 @@ func (pks *PredictKubeScaler) setupClientConn() error {
pc.InjectPublicClientMetadataInterceptor(pks.metadata.apiKey),
)

clientOpt = append(clientOpt, grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
ServerName: mlEngineHost,
}),
))

if err != nil {
return err
}
Expand Down

0 comments on commit 4cc3f77

Please sign in to comment.