Skip to content

KServe Path-Based Routing Implementation#3148

Merged
google-oss-prow[bot] merged 18 commits into
kubeflow:masterfrom
madmecodes:path-based-routing
Jun 9, 2025
Merged

KServe Path-Based Routing Implementation#3148
google-oss-prow[bot] merged 18 commits into
kubeflow:masterfrom
madmecodes:path-based-routing

Conversation

@madmecodes

@madmecodes madmecodes commented May 31, 2025

Copy link
Copy Markdown
Contributor

✏️ Summary of Changes

Problem Statement
Input: User request to implement path-based routing for KServe inference services
Requirement: Enable custom URL paths like /serving/namespace/service/v1/models/... to route to KServe services

Original
Client → istio-ingressgateway → isvc-sklearn-predictor-ingress VS → Service

New Path-Based Flow
Client → istio-ingressgateway → kserve-path-gateway → kserve-path-routing VS → knative-local-gateway → Service

First Attempt: Direct VirtualService
FAILED APPROACH

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: test-path-routing
spec:
  hosts: ["*"]  # Problem: Too broad
  gateways: ["kubeflow/kubeflow-gateway"]  # Problem: Conflicts with existing

Issues Encountered:

  1. VirtualService Conflicts: Existing KServe VirtualServices matched first
  2. Authority Matching: isvc-sklearn-predictor-ingress used authority prefix matching that intercepted requests
  3. Processing Order: Istio processed VirtualServices alphabetically, causing conflicts

Why New Host Creation?

  1. Conflict Avoidance: Existing VirtualServices match specific hosts
  2. Clean Separation: Path-based routing isolated from native KServe routing
  3. Precedence Control: Dedicated Gateway ensures our rules process first
  4. Maintainability: No interference with KServe's auto-generated routing
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: kserve-path-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      protocol: HTTP
    hosts:
    - "kserve-path.${NAMESPACE}.example.com"  # NEW HOST

Step 2: Create Isolated VirtualService

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: kserve-path-routing
spec:
  gateways:
  - kserve-path-gateway  # DEDICATED GATEWAY
  hosts:
  - "kserve-path.${NAMESPACE}.example.com"  # MATCHES GATEWAY
  http:
  - match:
    - uri:
        prefix: /serving/${NAMESPACE}/isvc-sklearn/
    rewrite:
      uri: /  # STRIP PATH PREFIX
    route:
    - destination:
        host: knative-local-gateway.istio-system.svc.cluster.local
      headers:
        request:
          set:
            Host: isvc-sklearn-predictor.${NAMESPACE}.svc.cluster.local

Output: {"predictions":[1]}

📦 Dependencies

#3098

✅ Contributor Checklist

  • I have tested these changes with kustomize. See Installation Prerequisites.
  • All commits are signed-off to satisfy the DCO check.
  • I have considered adding my company to the adopters page to support Kubeflow and help the community, since I expect help from the community for my issue (see 1. and 2.).

You can join the CNCF Slack and access our meetings at the Kubeflow Community website. Our channel on the CNCF Slack is here #kubeflow-platform.

@juliusvonkohout

juliusvonkohout commented Jun 3, 2025

Copy link
Copy Markdown
Member

Please no additional gateways. Gateway vreation is not allowed in user namespaces. just a second virtual service should be enough

@juliusvonkohout

Copy link
Copy Markdown
Member

Please rebase to master

Comment thread tests/gh-actions/test_kserve.sh Outdated
echo "=== KServe Predictor Service Labels ==="
kubectl get pods -n ${NAMESPACE} -l serving.knative.dev/service=isvc-sklearn-predictor-default --show-labels

echo "=== Creating dedicated Gateway for path-based routing ==="

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no dedicated gateway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And gateways are also forbidden in user namespaces. It should work without that as shown on slack.

Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@madmecodes madmecodes force-pushed the path-based-routing branch from 3160934 to bf5d90a Compare June 7, 2025 05:01
@google-oss-prow google-oss-prow Bot added size/M and removed size/L labels Jun 7, 2025
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@google-oss-prow google-oss-prow Bot added size/L and removed size/M labels Jun 7, 2025
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@madmecodes

Copy link
Copy Markdown
Contributor Author

same script working locally in kind cluster, but failing in pipeline debugging...

Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@juliusvonkohout

Copy link
Copy Markdown
Member

Thank you

/lgtm
/approve

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: juliusvonkohout

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot merged commit 80caf17 into kubeflow:master Jun 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants