diff --git a/config/configmap/configmap.yaml b/config/configmap/configmap.yaml index dafda19..8add0fa 100644 --- a/config/configmap/configmap.yaml +++ b/config/configmap/configmap.yaml @@ -12,6 +12,6 @@ data: } ingress: |- { - "ingressGateway": "paddleflow/paddleflow-gateway", - "ingressServiceName": "*" + "ingressGateway" : "istio-ingressgateway", + "ingressServiceName" : "istio-ingressgateway.istio-system.svc.cluster.local" } \ No newline at end of file diff --git a/config/samples/elasticserving_v1_paddle.yaml b/config/samples/elasticserving_v1_paddle.yaml index eaf7dd5..b6eb917 100644 --- a/config/samples/elasticserving_v1_paddle.yaml +++ b/config/samples/elasticserving_v1_paddle.yaml @@ -9,6 +9,5 @@ spec: storageUri: hub.baidubce.com/paddlepaddle/serving:latest runtimeVersion: paddleserving service: - minScale: 2 - # storageUri: nginx:latest - # runtimeVersion: nginx \ No newline at end of file + minScale: 1 + concurrency: "cpu" \ No newline at end of file diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index d2ac4ff..86cdc37 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -23,8 +23,8 @@ var ( // PaddleService resource defaults var ( - PaddleServiceDefaultCPU = "0.1" - PaddleServiceDefaultMemory = "128Mi" + PaddleServiceDefaultCPU = "0.2" + PaddleServiceDefaultMemory = "512Mi" PaddleServiceDefaultMinScale = 1 // 0 if scale-to-zero is desired PaddleServiceDefaultMaxScale = 10 // 0 means limitless PaddleServiceDefaultTimeout int64 = 300 diff --git a/pkg/controllers/elasticserving/resources/istio/virtualservice.go b/pkg/controllers/elasticserving/resources/istio/virtualservice.go index 170e748..cb73b49 100644 --- a/pkg/controllers/elasticserving/resources/istio/virtualservice.go +++ b/pkg/controllers/elasticserving/resources/istio/virtualservice.go @@ -2,6 +2,7 @@ package istio import ( elasticservingv1 "ElasticServing/pkg/apis/elasticserving/v1" + "ElasticServing/pkg/constants" "fmt" istiov1alpha3 "istio.io/api/networking/v1alpha3" @@ -31,15 +32,20 @@ func NewVirtualServiceBuilder(configMap *core.ConfigMap) *VirtualServiceBuilder ingressConfig.IngressGateway = istioIngressConfig.IngressGateway ingressConfig.IngressServiceName = istioIngressConfig.IngressServiceName + if ingressConfig.IngressGateway == "" || ingressConfig.IngressServiceName == "" { + panic(fmt.Errorf("Invalid ingress config, ingressGateway and ingressService are required.")) + } + return &VirtualServiceBuilder{ingressConfig: ingressConfig} } func (r *VirtualServiceBuilder) CreateVirtualService(paddlesvc *elasticservingv1.PaddleService) *v1alpha3.VirtualService { - clusterDomain := "cluster.local" + // clusterDomain := "cluster.local" prefix := fmt.Sprintf("/paddlepaddle/%s/%s/", paddlesvc.Namespace, paddlesvc.Name) rewrite := fmt.Sprintf("/paddlepaddle/%s/%s/", paddlesvc.Namespace, paddlesvc.Name) - service := fmt.Sprintf("%s.%s.svc.%s", paddlesvc.ObjectMeta.Name, paddlesvc.ObjectMeta.Namespace, clusterDomain) + // service := fmt.Sprintf("%s.%s.svc.%s", paddlesvc.Name, paddlesvc.Namespace, clusterDomain) + service := constants.DefaultServiceName(paddlesvc.Name) istioGateway := r.ingressConfig.IngressGateway host := r.ingressConfig.IngressServiceName @@ -50,10 +56,10 @@ func (r *VirtualServiceBuilder) CreateVirtualService(paddlesvc *elasticservingv1 Kind: "VirtualService", }, ObjectMeta: metav1.ObjectMeta{ - Name: paddlesvc.ObjectMeta.Name, - Namespace: paddlesvc.ObjectMeta.Namespace, - Labels: paddlesvc.ObjectMeta.Labels, - Annotations: paddlesvc.ObjectMeta.Annotations, + Name: paddlesvc.Name, + Namespace: paddlesvc.Namespace, + Labels: paddlesvc.Labels, + Annotations: paddlesvc.Annotations, }, Spec: istiov1alpha3.VirtualService{ Hosts: []string{host}, diff --git a/pkg/controllers/elasticserving/resources/knative/service.go b/pkg/controllers/elasticserving/resources/knative/service.go index 70fd000..12574a0 100644 --- a/pkg/controllers/elasticserving/resources/knative/service.go +++ b/pkg/controllers/elasticserving/resources/knative/service.go @@ -52,6 +52,15 @@ func (r *ServiceBuilder) CreateService(serviceName string, paddlesvc *elasticser } concurrency := int64(paddlesvcSpec.Service.Target) + command := []string{"/bin/bash", "-c"} + args := []string{ + `pip install paddle-serving-server==0.4.0; + pip install paddle-serving-client==0.4.0; + pip install paddle-serving-app==0.2.0; + wget --no-check-certificate https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz; + tar -xzf uci_housing.tar.gz && + python -m paddle_serving_server.serve --model uci_housing_model --thread 1 --port 9292`, + } service := &knservingv1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: serviceName, @@ -79,9 +88,14 @@ func (r *ServiceBuilder) CreateService(serviceName string, paddlesvc *elasticser Ports: []core.ContainerPort{ {ContainerPort: r.serviceConfig.Port, Name: constants.PaddleServiceDefaultPodName, Protocol: core.ProtocolTCP}, }, + Command: command, + Args: args, ReadinessProbe: &core.Probe{ - SuccessThreshold: 5, - InitialDelaySeconds: 5, + SuccessThreshold: 1, + InitialDelaySeconds: 0, + TimeoutSeconds: 1, + FailureThreshold: 100, + PeriodSeconds: 100, Handler: core.Handler{ TCPSocket: &core.TCPSocketAction{ Port: intstr.FromInt(0), @@ -91,7 +105,6 @@ func (r *ServiceBuilder) CreateService(serviceName string, paddlesvc *elasticser Resources: resources, }, }, - //RestartPolicy: core.RestartPolicyAlways, }, }, },