knative-extensions / net-istio

A Knative ingress controller for Istio.
Apache License 2.0
76 stars 89 forks source link

multi headers is be override in knative ingress #847

Closed wu0407 closed 2 years ago

wu0407 commented 2 years ago

knative version: v1.1.0 net-istio version: v1.1.0

  1. create knative ingress:
    apiVersion: networking.internal.knative.dev/v1alpha1
    kind: Ingress
    metadata:
    annotations:
      networking.knative.dev/ingress.class: istio.ingress.networking.knative.dev
    name: url-1
    namespace: default
    spec:
    httpOption: Enabled
    rules:
    - hosts:
    - url.com
    http:
      paths:
      - headers:
          version:
            exact: canary
          abc:
            exact: abc
        path: /url-1
        splits:
        - appendHeaders:
            Knative-Serving-Namespace: default
            Knative-Serving-Revision: example-nginx-00006
          percent: 100
          serviceName: example-nginx-00006
          serviceNamespace: default
          servicePort: 80
    visibility: ExternalIP
  2. net-istio will create virtualservice:
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
    annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.internal.knative.dev/v1alpha1","kind":"Ingress","metadata":{"annotations":{"networking.knative.dev/ingress.class":"istio.ingress.networking.knative.dev"},"name":"url-1","namespace":"default"},"spec":{"httpOption":"Enabled","rules":[{"hosts":["url.com"],"http":{"paths":[{"headers":{"version":{"exact":"canary"},"abc":{"exact":"abc"}},"path":"/url-1","splits":[{"appendHeaders":{"Knative-Serving-Namespace":"default","Knative-Serving-Revision":"example-nginx-00006"},"percent":100,"serviceName":"example-nginx-00006","serviceNamespace":"default","servicePort":80}]}]},"visibility":"ExternalIP"}]}}
    networking.knative.dev/ingress.class: istio.ingress.networking.knative.dev
    creationTimestamp: "2022-01-12T09:15:03Z"
    generation: 29
    labels:
    networking.internal.knative.dev/ingress: url-1
    name: url-1-ingress
    namespace: default
    ownerReferences:
    - apiVersion: networking.internal.knative.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Ingress
    name: url-1
    uid: b731f15b-6e9d-421c-86d0-078957f62dfe
    spec:
    gateways:
    - knative/knative-ingress-gateway
    hosts:
    - url.com
    http:
    - headers:
      request:
        set:
          K-Network-Hash: 4def9432b3a05cbe2f2d5a38cd88f1884bbe01509b41ee01272a685e05b38b00
    match:
    - authority:
        prefix: url.com
      gateways:
      - knative/knative-ingress-gateway
      headers:
        K-Network-Hash:
          exact: override
      uri:
        prefix: /url-1
    retries: {}
    route:
    - destination:
        host: example-nginx-00006.default.svc.cluster.local
        port:
          number: 80
      headers:
        request:
          set:
            Knative-Serving-Namespace: default
            Knative-Serving-Revision: example-nginx-00006
      weight: 100
    - match:
    - authority:
        prefix: url.com
      gateways:
      - knative/knative-ingress-gateway
      headers:
        abc:
          exact: abc
      uri:
        prefix: /url-1
    retries: {}
    route:
    - destination:
        host: example-nginx-00006.default.svc.cluster.local
        port:
          number: 80
      headers:
        request:
          set:
            Knative-Serving-Namespace: default
            Knative-Serving-Revision: example-nginx-00006
      weight: 100
  3. The first header version: canary is to be override.

related code: https://github.com/knative-sandbox/net-istio/blob/ab9dfc86f07f3ce0da06f3cc42282fcf2e0ad82c/pkg/reconciler/ingress/resources/virtual_service.go#L264-L272

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

zhouguangming commented 6 months ago

+1 @igsong