diff --git a/pkg/scalers/predictkube_scaler.go b/pkg/scalers/predictkube_scaler.go index 19e32f6fb55..a12d86fa3c3 100644 --- a/pkg/scalers/predictkube_scaler.go +++ b/pkg/scalers/predictkube_scaler.go @@ -2,6 +2,7 @@ package scalers import ( "context" + "crypto/tls" "errors" "fmt" "math" @@ -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" @@ -36,8 +38,8 @@ const ( ) var ( - mlEngineHost = "predictkube-dev.dysnix.org" - mlEnginePort = 8080 + mlEngineHost = "api.predictkube.com" + mlEnginePort = 443 defaultStep = time.Minute * 5 ) @@ -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{ @@ -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 }