Skip to content

Commit

Permalink
Merge pull request #23 from jinminhao/buildAnnotations
Browse files Browse the repository at this point in the history
Part of bugs is fixed
  • Loading branch information
jinminhao authored Jan 15, 2021
2 parents abffb39 + e7ba05b commit 4438672
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config/configmap/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ data:
}
ingress: |-
{
"ingressGateway": "paddleflow/paddleflow-gateway",
"ingressServiceName": "*"
"ingressGateway" : "istio-ingressgateway",
"ingressServiceName" : "istio-ingressgateway.istio-system.svc.cluster.local"
}
5 changes: 2 additions & 3 deletions config/samples/elasticserving_v1_paddle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ spec:
storageUri: hub.baidubce.com/paddlepaddle/serving:latest
runtimeVersion: paddleserving
service:
minScale: 2
# storageUri: nginx:latest
# runtimeVersion: nginx
minScale: 1
concurrency: "cpu"
4 changes: 2 additions & 2 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions pkg/controllers/elasticserving/resources/istio/virtualservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package istio

import (
elasticservingv1 "ElasticServing/pkg/apis/elasticserving/v1"
"ElasticServing/pkg/constants"
"fmt"

istiov1alpha3 "istio.io/api/networking/v1alpha3"
Expand Down Expand Up @@ -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
Expand All @@ -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},
Expand Down
19 changes: 16 additions & 3 deletions pkg/controllers/elasticserving/resources/knative/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -91,7 +105,6 @@ func (r *ServiceBuilder) CreateService(serviceName string, paddlesvc *elasticser
Resources: resources,
},
},
//RestartPolicy: core.RestartPolicyAlways,
},
},
},
Expand Down

0 comments on commit 4438672

Please sign in to comment.