我注意到,每当我部署一个模型时,就会有两个服务,例如
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
所以只涉及一个吊舱,我认为这些端口是从不同的容器映射的:
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"
}
]
一个更具体的问题是,为什么需要这么多端口?
是的,看起来您的pod中有两个容器。
第一项服务:
iris-model-default
➡️seldon-container-engine
HTTP:8000:8000
和GRPC:5001:8000
第二项服务:
iris-model-default-classifier
➡️classifier
HTTP: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
如果你想了解为什么这两个容器/服务背后的理由,你可能会深入了解运营商本身🔧.