Home > Software engineering >  Can't access to my deployed model with Seldon Core on K8s for predicting values
Can't access to my deployed model with Seldon Core on K8s for predicting values

Time:04-13

I've a model for predicting MNIST dataset values, but while configuring my ingress.yaml and I did specify the host that I can access to with my curl command, it gives me an error saying

0curl: (6) Could not resolve host: mnist.testing

And I did verify that my pod is running. Here's my ingress file :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mnist-classifier
  namespace: my-model
  annotations:
    certmanager.k8s.io/acme-challenge-type: dns01
    certmanager.k8s.io/acme-dns01-provider: clouddns
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod-dns
    kubernetes.io/ingress.allow-http: "true"
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
  
spec: 
  rules:
  - host: mnist.testing
    http:
      paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: tfserving-tfserving
                port:
                  number: 8000
  tls:
  - hosts:
    - '*.testing'
    secretName: dns01-tls

I'm deploying my Model with Seldon Core, and this is my Deployment.yaml :

apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: tfserving
  namespace: my-model
spec:
  name: ala-deployment
  predictors:
  - graph:
      children: []
      implementation: TENSORFLOW_SERVER
      modelUri: gs://seldon-aladin/mnist 
      serviceAccountName: user-gcp-ala
      name: mnist-model
    name: toto
    replicas: 1

and this is my python code for the prediction from the url:

mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
to_predict = tf.reshape(x_test[3], [1, 784])
payload = {"data":{"tensor":{"shape": [1,784], "values": to_predict}}}

!curl  -X POST http://mnist.testing/predict -d payload -H "Content-Type: application/json"

Ps: I'm a beginner on kubernetes, and I've been stuck on this for a week. And I'm following this Tutorial

The result of my curl command when I add --http0.9 -v --trace-ascii -

== Info:   Trying 127.0.0.1:9000...
== Info: Connected to mnist.plz (127.0.0.1) port 9000 (#0)
=> Send header, 137 bytes (0x89)
0000: POST /predict HTTP/1.1
0018: Host: mnist.plz:9000
002e: User-Agent: curl/7.79.1
0047: Accept: */*
0054: Content-Type: application/json
0074: Content-Length: 4
0087: 
=> Send data, 4 bytes (0x4)
0000: data
<= Recv data, 10 bytes (0xa)
Output exceeds the size limit. Open the full output data in a text editor
Warning: --trace-ascii overrides an earlier trace/verbose option
Note: Unnecessary use of -X or --request, POST is already inferred.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    14    0    10  100     4      8      3  0:00:01  0:00:01 --:--:--    11
100    14    0    10  100     4      4      1  0:00:04  0:00:02  0:00:02     6
100    14    0    10  100     4      3      1  0:00:04  0:00:03  0:00:01     4

CodePudding user response:

You may need to convert the numpy array with tolist. Can you output what you are sending via curl to confirm?

CodePudding user response:

You may try to do a port forwarding to your pod before accessing to it.

kubectl port-forward your-pod-name -n your-namespace NewPortNumber:PreviousPortNumber 

And you can get your pod name by the command :

kubectl get pods -n your-namespace

and finnally try to do your request

!curl  -X POST http://mnist.testing:NewPortNumber/predict -d payload -H "Content-Type: application/json"
  • Related