Files
Yuan TangandGitHub 5a767fcf1c feat: Support customizable deployment strategy for RawDeployment mode. Fixes #3452 (#3603)
* feat: Support customizable deployment strategy for RawDeployment mode

Signed-off-by: Yuan Tang <[email protected]>

* regen

Signed-off-by: Yuan Tang <[email protected]>

* lint

Signed-off-by: Yuan Tang <[email protected]>

* Correctly apply rollingupdate

Signed-off-by: Yuan Tang <[email protected]>

* address comments

Signed-off-by: Yuan Tang <[email protected]>

* Add validation

Signed-off-by: Yuan Tang <[email protected]>

---------

Signed-off-by: Yuan Tang <[email protected]>
2024-05-09 10:38:08 -04:00

3.7 KiB

KfServing Logger demo

We create a message dumper Knative service to print out CloudEvents it receives:

In [ ]:
!pygmentize message-dumper.yaml
In [ ]:
!kubectl apply -f message-dumper.yaml

Create an sklearn model with associated logger to push events to the message logger URL.

In [ ]:
!pygmentize sklearn-logging.yaml
In [ ]:
!kubectl apply -f sklearn-logging.yaml
In [ ]:
CLUSTER_IPS = !(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
CLUSTER_IP = CLUSTER_IPS[0]
print(CLUSTER_IP)
In [ ]:
SERVICE_HOSTNAMES = !(kubectl get inferenceservice sklearn-iris -o jsonpath='{.status.url}' | cut -d "/" -f 3)
SERVICE_HOSTNAME = SERVICE_HOSTNAMES[0]
print(SERVICE_HOSTNAME)
In [ ]:
import requests


def predict(X, name, svc_hostname, cluster_ip):
    formData = {"instances": X}
    headers = {}
    headers["Host"] = svc_hostname
    res = requests.post(
        "http://" + cluster_ip + "/v1/models/" + name + ":predict",
        json=formData,
        headers=headers,
    )
    if res.status_code == 200:
        return res.json()
    else:
        print("Failed with ", res.status_code)
        return []
In [ ]:
predict([[6.8, 2.8, 4.8, 1.4]], "sklearn-iris", SERVICE_HOSTNAME, CLUSTER_IP)
In [ ]:
!kubectl logs  $(kubectl get pod -l serving.knative.dev/configuration=message-dumper -o jsonpath='{.items[0].metadata.name}') user-container
In [ ]:
!kubectl delete -f sklearn-logging.yaml
In [ ]:
!kubectl delete -f message-dumper.yaml
In [ ]: