serving icon indicating copy to clipboard operation
serving copied to clipboard

Support configurable Istio Virtualservice match prefix/rewrite of a Knative Service

Open husnialhamdani opened this issue 6 months ago • 2 comments

/area networking

Describe the feature

Is there a way to customize/configure a generated Istio virtualservice of Knative Service to support HTTP match prefix and Rewrite?

For example, when we create a Knative Service like below:

kn service create hello \              
--image ghcr.io/knative/helloworld-go:latest \
--port 8080 \
--env TARGET=World

We have a generated a default Istio Virtualservice of that particular Knative service:

k get virtualservice hello-mesh -o yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  annotations:
    networking.internal.knative.dev/rollout: '{"configurations":[{"configurationName":"hello","percent":100,"revisions":[{"revisionName":"hello-00001","percent":100}],"stepParams":{}}]}'
    networking.knative.dev/ingress.class: istio.ingress.networking.knative.dev
    serving.knative.dev/creator: system:serviceaccount:kube-system:admin-user
    serving.knative.dev/lastModifier: system:serviceaccount:kube-system:admin-user
  creationTimestamp: "2023-12-24T11:51:04Z"
  generation: 1
  labels:
    networking.internal.knative.dev/ingress: hello
    serving.knative.dev/route: hello
    serving.knative.dev/routeNamespace: knative-test
  name: hello-mesh
  namespace: knative-test
  ownerReferences:
  - apiVersion: networking.internal.knative.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Ingress
    name: hello
    uid: 412299a9-2a9e-4eb6-aa7e-30fccacdb4dc
  resourceVersion: "224534334"
  uid: 7bb7a0eb-efc1-424e-80a7-0417ba3a4e89
spec:
  gateways:
  - mesh
  hosts:
  - hello.knative-test
  - hello.knative-test.svc
  - hello.knative-test.svc.cluster.local
  http:
  - headers:
      request:
        set:
          K-Network-Hash: 28e1a72def58a951b9d0deaf194c8e2611826a990936a17a40f4e232b73b4bc5
    match:
    - authority:
        prefix: hello.knative-test
      gateways:
      - mesh
      headers:
        K-Network-Hash:
          exact: override
    retries: {}
    route:
    - destination:
        host: hello-00001.knative-test.svc.cluster.local
        port:
          number: 80
      headers:
        request:
          set:
            Knative-Serving-Namespace: knative-test
            Knative-Serving-Revision: hello-00001
      weight: 100
  - match:
    - authority:
        prefix: hello.knative-test
      gateways:
      - mesh
    retries: {}
    route:
    - destination:
        host: hello-00001.knative-test.svc.cluster.local
        port:
          number: 80
      headers:
        request:
          set:
            Knative-Serving-Namespace: knative-test
            Knative-Serving-Revision: hello-00001
      weight: 100

For some of our application needs, required to be pointed to some custom base path.

husnialhamdani avatar Dec 24 '23 12:12 husnialhamdani

Take a look at the routing example here - https://github.com/knative/docs/tree/main/code-samples/serving/knative-routing-go

This is the best option for now. Let us know.

dprotaso avatar Mar 20 '24 10:03 dprotaso