如何使用 port-forward 快速启动 seldon-core?

How to seldon-core quick-start on kind with port-forward?

根据文档,我尝试设置 Seldon-Core 快速启动 https://docs.seldon.io/projects/seldon-core/en/v1.11.1/workflow/github-readme.html

我没有 LoadBalancer,所以我想使用端口转发来访问该服务。

我运行以下用于设置系统的脚本:

#!/bin/bash -ev
kind create cluster --name seldon

kubectl cluster-info --context kind-seldon
sleep 10
kubectl get pods -A

istioctl install -y
sleep 10
kubectl get pods -A

kubectl create namespace seldon-system
kubens seldon-system
helm install seldon-core seldon-core-operator \
     --repo https://storage.googleapis.com/seldon-charts \
     --set usageMetrics.enabled=true \
     --namespace seldon-system \
     --set istio.enabled=true
sleep 100
kubectl get validatingwebhookconfigurations
kubectl create namespace modelns
kubens modelns
kubectl apply -f - << END           
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: iris-model
  namespace: modelns
spec:
  name: iris
  predictors:
  - graph:
      implementation: SKLEARN_SERVER
      modelUri: gs://seldon-models/v1.12.0-dev/sklearn/iris
      name: classifier
    name: default
    replicas: 1
END
sleep 100
kubectl get pods -A
kubectl get svc -A
INGRESS_GATEWAY_SERVICE=$(kubectl get svc --namespace istio-system --selector="app=istio-ingressgateway" --output jsonpath='{.items[0].metadata.name}')
kubectl port-forward --namespace istio-system svc/${INGRESS_GATEWAY_SERVICE} 8080:80 &

我想端口转发参数 8080:80 可能是错误的。

我正在使用以下脚本进行测试:

#!/bin/bash -ev

export INGRESS_HOST=localhost
export INGRESS_PORT=8080
SERVICE_HOSTNAME=$(kubectl get inferenceservice sklearn-iris -n kserve-test -o jsonpath='{.status.url}' | cut -d "/" -f 3)

curl -X POST http://$INGRESS_HOST:$INGRESS_PORT/seldon/modelns/iris-model/api/v1.0/predictions \
    -H 'Content-Type: application/json' \
    -d '{ "data": { "ndarray": [1,2,3,4] } }'

但是我得到了以下错误:

Handling connection for 8080
E1012 10:52:32.074812   
52896 portforward.go:400] an error occurred forwarding 8080 -> 8080: 
error forwarding port 8080 to pod b9bd4ff03c6334f4af632044fe54e1c2531e95976a5fe074e30b4258d145508a, 
uid : failed to execute portforward in network namespace "/var/run/netns/cni-2b4d8573-3cfe-c70e-1c36-e0dc53cbd936": failed to connect to localhost:8080 inside namespace "b9bd4ff03c6334f4af632044fe54e1c2531e95976a5fe074e30b4258d145508a",
 IPv4: dial tcp4 127.0.0.1:8080: connect: connection refused IPv6 dial tcp6 [::1]:8080: connect: connection refused

有人知道如何解决这个问题吗?什么是正确的端口转发参数?

如果安装时启用了 istio,则还需要安装 istio 网关。

我已经测试了你的流程,它没有工作,然后在安装以下 istio 网关后工作。

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: seldon-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

您可以在此处阅读有关 Seldon Core 上的 istio 配置的更多信息:https://docs.seldon.io/projects/seldon-core/en/latest/ingress/istio.html