3

我注意到每当我部署一个模型时,都会有两种服务,例如

kubectl get service -n model-namespace 
NAME                            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE
iris-model-default              ClusterIP   10.96.82.232   <none>        8000/TCP,5001/TCP   8h
iris-model-default-classifier   ClusterIP   10.96.76.141   <none>        9000/TCP            8h

我想知道为什么我们有两个而不是一个。

三个端口(8000、9000、5001)分别是干什么用的?我应该使用哪一个?

清单 yaml 是

apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: iris-model
  namespace: model-namespace
spec:
  name: iris
  predictors:
  - graph:
      implementation: SKLEARN_SERVER
      modelUri: gs://seldon-models/sklearn/iris
      name: classifier
    name: default
    replicas: 1

来自https://docs.seldon.io/projects/seldon-core/en/v1.1.0/workflow/quickstart.html

CRD 定义似乎在这里,以防万一它有用。

k describe service/iris-model-default
Name:              iris-model-default
Namespace:         model-namespace
Labels:            app.kubernetes.io/managed-by=seldon-core
                   seldon-app=iris-model-default
                   seldon-deployment-id=iris-model
Annotations:       getambassador.io/config:
                     ---
                     apiVersion: ambassador/v1
                     kind: Mapping
                     name: seldon_model-namespace_iris-model_default_rest_mapping
                     prefix: /seldon/model-namespace/iris-model/
                     rewrite: /
                     service: iris-model-default.model-namespace:8000
                     timeout_ms: 3000
                     ---
                     apiVersion: ambassador/v1
                     kind: Mapping
                     name: seldon_model-namespace_iris-model_default_grpc_mapping
                     grpc: true
                     prefix: /(seldon.protos.*|tensorflow.serving.*)/.*
                     prefix_regex: true
                     rewrite: ""
                     service: iris-model-default.model-namespace:5001
                     timeout_ms: 3000
                     headers:
                       namespace: model-namespace
                       seldon: iris-model
Selector:          seldon-app=iris-model-default
Type:              ClusterIP
IP:                10.96.82.232
Port:              http  8000/TCP
TargetPort:        8000/TCP
Endpoints:         172.18.0.17:8000
Port:              grpc  5001/TCP
TargetPort:        8000/TCP
Endpoints:         172.18.0.17:8000
Session Affinity:  None
Events:            <none>
k describe service/iris-model-default-classifier 
Name:              iris-model-default-classifier
Namespace:         model-namespace
Labels:            app.kubernetes.io/managed-by=seldon-core
                   default=true
                   model=true
                   seldon-app-svc=iris-model-default-classifier
                   seldon-deployment-id=iris-model
Annotations:       <none>
Selector:          seldon-app-svc=iris-model-default-classifier
Type:              ClusterIP
IP:                10.96.76.141
Port:              http  9000/TCP
TargetPort:        9000/TCP
Endpoints:         172.18.0.17:9000
Session Affinity:  None
Events:            <none>
k get pods --show-labels
NAME                                               READY   STATUS    RESTARTS   AGE   LABELS
iris-model-default-0-classifier-579765fc5b-rm6np   2/2     Running   0          10h   app.kubernetes.io/managed-by=seldon-core,app=iris-model-default-0-classifier,fluentd=true,pod-template-hash=579765fc5b,seldon-app-svc=iris-model-default-classifier,seldon-app=iris-model-default,seldon-deployment-id=iris-model,version=default

所以只涉及一个 pod,我认为这些端口是从不同的容器映射的:

k get pods -o json | jq '.items[].spec.containers[] | .name, .ports'                                                                                                                           [0] 0s 
"classifier"
[
  {
    "containerPort": 6000,
    "name": "metrics",
    "protocol": "TCP"
  },
  {
    "containerPort": 9000,
    "name": "http",
    "protocol": "TCP"
  }
]
"seldon-container-engine"
[
  {
    "containerPort": 8000,
    "protocol": "TCP"
  },
  {
    "containerPort": 8000,
    "name": "metrics",
    "protocol": "TCP"
  }
]

一个更罕见的问题是为什么需要这么多端口?

4

1 回答 1

1

是的,看起来您的 pod 中有 2 个容器。

第一项服务:

iris-model-default➡️ seldon-container-engineHTTP:8000:8000和 GRPC:5001:8000

第二项服务:

iris-model-default-classifier➡️ classifierHTTP:(9000:9000内部使用的 6000 看起来像指标)

你没有提到,但听起来像部署了分类器:

apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: iris-model
  namespace: seldon
spec:
  name: iris
  predictors:
  - graph:
      implementation: SKLEARN_SERVER
      modelUri: gs://seldon-models/sklearn/iris
      name: classifier
    name: default
    replicas: 1

如果您想找出这两个容器/服务背后的基本原理,您可能已经深入了解了运营商本身。

于 2020-07-22T05:34:56.077 回答