KServe external ingress validation

Scenario - KServe External Ingress Validation — V1, V2/Triton and OpenAI-Compatible Endpoints

Purpose

Validate that KServe inference endpoints work correctly through the external ingress for:

  • KServe V1

  • KServe V2 / Triton

  • OpenAI-compatible endpoints

The scenario also verifies the backend directly through port-forward where needed.

Environment setup

Set your kubeconfig:

export KUBECONFIG=/path/to/your/KUBECONFIG

Set your namespace:

export NS=your-namespace

Verify:

echo $KUBECONFIG
echo $NS

Scenario 1 — KServe V1

1.1 Create sklearn-iris

kubectl apply -n $NS -f - <<'EOF'
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: sklearn-iris
spec:
  predictor:
    model:
      modelFormat:
        name: sklearn
      storageUri: "gs://kfserving-examples/models/sklearn/1.0/model"
      resources:
        requests:
          cpu: "100m"
          memory: "512Mi"
        limits:
          cpu: "1"
          memory: "1Gi"
EOF

1.2 Verify InferenceService and pod

kubectl get isvc sklearn-iris -n $NS -o wide
kubectl get pods -n $NS | grep sklearn

Expected result:

The InferenceService should reach:

READY=True

The predictor pod should reach:

3/3 Running

1.3 Store the external URL

V1_URL=$(kubectl get isvc sklearn-iris -n $NS -o jsonpath='{.status.url}')
echo $V1_URL

Expected result:

A valid HTTPS URL should be returned.

Example format:

https://sklearn-iris-<namespace>-<cluster-domain>

1.5 Test V1 through the external ingress

curl -i "$V1_URL/v1/models/sklearn-iris:predict" -H "Cookie: $COOKIE" -H "Content-Type: application/json" -d '{"instances":[[5.1,3.5,1.4,0.2],[6.7,3.1,4.7,1.5]]}'

Expected result:

HTTP/2 200

The response should contain predictions, for example:

{"predictions":[0,1]}

Scenario 2 — KServe V2 / Triton

If namespace quota is limited, remove the V1 InferenceService before creating Triton:

kubectl delete isvc sklearn-iris -n $NS --ignore-not-found

2.1 Create Triton InferenceService

kubectl apply -n $NS -f - <<'EOF'
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: torchscript-cifar10
spec:
  predictor:
    model:
      modelFormat:
        name: triton
      protocolVersion: v2
      storageUri: "gs://kfserving-examples/models/torchscript"
      runtimeVersion: "20.10-py3"
      env:
        - name: OMP_NUM_THREADS
          value: "1"
      resources:
        requests:
          cpu: "1"
          memory: "2Gi"
        limits:
          cpu: "1"
          memory: "2Gi"
EOF

2.2 Verify InferenceService and pod

kubectl get isvc torchscript-cifar10 -n $NS -o wide
kubectl get pods -n $NS | grep torchscript

Expected result:

The InferenceService should reach:

READY=True

The predictor pod should reach:

3/3 Running

2.3 Store the external URL

V2_URL=$(kubectl get isvc torchscript-cifar10 -n $NS -o jsonpath='{.status.url}')
echo $V2_URL

Expected result:

A valid HTTPS URL should be returned.

2.4 Download the V2 inference payload

curl -o /tmp/input.json https://raw.githubusercontent.com/kserve/kserve/master/docs/samples/v1beta1/triton/torchscript/input.json

Expected result:

The file should be downloaded successfully:

ls -lh /tmp/input.json

2.5 Verify V2 backend directly with port-forward

Terminal 1

POD=$(kubectl get pod -n $NS -l serving.kserve.io/inferenceservice=torchscript-cifar10 -o jsonpath='{.items[0].metadata.name}')

kubectl port-forward -n $NS pod/$POD 8080:8080

Keep this terminal running.

Terminal 2 — model metadata

curl -i http://localhost:8080/v2/models/cifar10

Expected result:

HTTP/1.1 200 OK

The response should contain model metadata such as:

{
  "name": "cifar10",
  "versions": ["1"],
  "platform": "pytorch_libtorch"
}

Terminal 2 — V2 inference

curl -i -X POST http://localhost:8080/v2/models/cifar10/infer -H "Content-Type: application/json" -d @/tmp/input.json

Expected result:

HTTP/1.1 200 OK

The response should contain Triton inference output.

After the backend verification, stop port-forward in Terminal 1:

Ctrl+C

2.6 Test external V2 endpoint without authentication

GET model metadata

curl -i "$V2_URL/v2/models/cifar10"

POST inference

curl -i -X POST "$V2_URL/v2/models/cifar10/infer" -H "Content-Type: application/json" --data-binary @/tmp/input.json

Expected result:

If the external ingress requires Kubeflow authentication, the request should be redirected to the authentication flow, for example:

HTTP/2 302
location: /dex/auth?...

2.7 Test external V2 endpoint with authentication

GET model metadata

curl -i "$V2_URL/v2/models/cifar10" -H "Cookie: $COOKIE"

Expected result:

HTTP/2 200

The response should contain model metadata.

POST inference

curl -i -X POST "$V2_URL/v2/models/cifar10/infer" -H "Cookie: $COOKIE" -H "Content-Type: application/json" --data-binary @/tmp/input.json

Expected result:

HTTP/2 200

The response should contain Triton inference output.

Scenario 3 — OpenAI-Compatible KServe Endpoint

This scenario uses a small Hugging Face model running on CPU.

If namespace quota is limited, remove the previous InferenceServices first:

kubectl delete isvc torchscript-cifar10 -n $NS --ignore-not-found
kubectl delete isvc sklearn-iris -n $NS --ignore-not-found

3.1 Create CPU-only Qwen InferenceService

kubectl apply -n $NS -f - <<'EOF'
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: qwen-cpu
spec:
  predictor:
    model:
      modelFormat:
        name: huggingface
      args:
        - --model_name=qwen
        - --backend=huggingface
        - --task=text_generation
      storageUri: "hf://Qwen/Qwen2-0.5B-Instruct"
      resources:
        requests:
          cpu: "2"
          memory: "4Gi"
        limits:
          cpu: "3"
          memory: "6Gi"
EOF

3.2 Verify InferenceService and pod

kubectl get isvc qwen-cpu -n $NS -o wide
kubectl get pods -n $NS | grep qwen

Expected result:

The InferenceService should reach:

READY=True

The predictor pod should reach:

3/3 Running

3.3 Store the external URL

OPENAI_URL=$(kubectl get isvc qwen-cpu -n $NS -o jsonpath='{.status.url}')
echo $OPENAI_URL

Expected result:

A valid HTTPS URL should be returned.

3.4 Optional log verification

POD=$(kubectl get pod -n $NS -l serving.kserve.io/inferenceservice=qwen-cpu -o jsonpath='{.items[0].metadata.name}')

kubectl logs -n $NS "$POD" -c kserve-container --tail=100

Expected result:

The logs should show that the model was loaded successfully and that OpenAI endpoints were registered.

Example:

OpenAI endpoints registered

3.5 Verify OpenAI backend directly with port-forward

Terminal 1

POD=$(kubectl get pod -n $NS -l serving.kserve.io/inferenceservice=qwen-cpu -o jsonpath='{.items[0].metadata.name}')

kubectl port-forward -n $NS pod/$POD 8080:8080

Keep this terminal running.

Terminal 2 — Chat Completions

curl -i -X POST http://localhost:8080/openai/v1/chat/completions -H "Content-Type: application/json" -d '{
  "model": "qwen",
  "messages": [
    {"role": "user", "content": "Say hello in one short sentence."}
  ],
  "max_tokens": 20
}'

Expected result:

HTTP/1.1 200 OK

The response should contain a valid OpenAI-compatible chat completion.

Terminal 2 — Completions

curl -i -X POST http://localhost:8080/openai/v1/completions -H "Content-Type: application/json" -d '{
  "model": "qwen",
  "prompt": "Say hello in one short sentence.",
  "max_tokens": 20
}'

Expected result:

HTTP/1.1 200 OK

The response should contain a valid OpenAI-compatible completion.

After the backend verification, stop port-forward in Terminal 1:

Ctrl+C

3.6 Test OpenAI Chat Completions through the external ingress

curl -i -X POST "$OPENAI_URL/openai/v1/chat/completions" -H "Cookie: $COOKIE" -H "Content-Type: application/json" -d '{
  "model": "qwen",
  "messages": [
    {"role": "user", "content": "Say hello in one short sentence."}
  ],
  "max_tokens": 20
}'

Expected result:

HTTP/2 200

The response should contain a valid OpenAI-compatible chat completion.

3.7 Test OpenAI Completions through the external ingress

curl -i -X POST "$OPENAI_URL/openai/v1/completions" -H "Cookie: $COOKIE" -H "Content-Type: application/json" -d '{
  "model": "qwen",
  "prompt": "Say hello in one short sentence.",
  "max_tokens": 20
}'

Expected result:

HTTP/2 200

The response should contain a valid OpenAI-compatible completion.

Cleanup

kubectl delete isvc sklearn-iris torchscript-cifar10 qwen-cpu -n $NS --ignore-not-found