kmesh-net / kmesh

High Performance ServiceMesh Data Plane Based on Programmable Kernel
https://kmesh.net
Apache License 2.0
466 stars 70 forks source link

Can't use traffic mirroring capabilities of Kmesh #823

Open noobwei opened 2 months ago

noobwei commented 2 months ago

What happened:

Can't use traffic mirroring capabilities of Kmesh:

Completed the task of transferring all traffic to v1: image Failed to the task of traffic mirroring: image

What you expected to happen:

Traffic from v1 should be mirrored to v2

How to reproduce it (as minimally and precisely as possible):

  1. https://istio.io/latest/docs/tasks/traffic-management/mirroring/#before-you-begin
  2. As we worked in ambient mode, I deploied a waypoint pod for 'httpbin' service. Refer to https://kmesh.net/en/docs/userguide/install_waypoint/
  3. When I refered to https://istio.io/latest/docs/tasks/traffic-management/mirroring/#creating-a-default-routing-policy, error happened as: error: error parsing STDIN: error converting YAML to JSON: yaml: line 6: did not find expected key. So I post my yaml here.
kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
    - httpbin
  http:
    - route:
        - destination:
            host: httpbin
            subset: v1
          weight: 100
---
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
  name: httpbin
spec:
  host: httpbin
  subsets:
    - name: v1
      labels:
        version: v1
    - name: v2
      labels:
        version: v2
EOF
kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
    - httpbin
  http:
    - route:
        - destination:
            host: httpbin
            subset: v1
          weight: 100
      mirror:
        host: httpbin
        subset: v2
      mirrorPercentage:
        value: 100.0
EOF
  1. Then test refer to the istio website
    kubectl exec deploy/sleep -c sleep -- curl -sS http://httpbin:8000/headers
    kubectl logs deploy/httpbin-v1 -c httpbin
    kubectl logs deploy/httpbin-v2 -c httpbin

Anything else we need to know?:

Environment:

YaoZengzeng commented 2 months ago

The mirror-related config has indeed issued, because it already contains requestMirrorPolicies field:

    {
        "name": "inbound-vip|8000|http|httpbin.test.svc.cluster.local",
        "virtualHosts": [
            {
                "name": "inbound|http|8000",
                "domains": [
                    "*"
                ],
                "routes": [
                    {
                        "match": {
                            "prefix": "/"
                        },
                        "route": {
                            "cluster": "inbound-vip|8000|http/v1|httpbin.test.svc.cluster.local",
                            "timeout": "0s",
                            "retryPolicy": {
                                "retryOn": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes",
                                "numRetries": 2,
                                "retryHostPredicate": [
                                    {
                                        "name": "envoy.retry_host_predicates.previous_hosts",
                                        "typedConfig": {
                                            "@type": "type.googleapis.com/envoy.extensions.retry.host.previous_hosts.v3.PreviousHostsPredicate"
                                        }
                                    }
                                ],
                                "hostSelectionRetryMaxAttempts": "5",
                                "retriableStatusCodes": [
                                    503
                                ]
                            },
                            "requestMirrorPolicies": [
                                {
                                    "cluster": "outbound|8000|v2|httpbin.test.svc.cluster.local",
                                    "runtimeFraction": {
                                        "defaultValue": {
                                            "numerator": 100
                                        }
                                    },
                                    "traceSampled": false
                                }
                            ],
                            "maxGrpcTimeout": "0s"
                        },

But an error was reported during the access:

kubectl exec -n deploy/sleep -c sleep -- curl -sS http://httpbin:8000/headers
curl: (7) Failed to connect to httpbin port 8000 after 1 ms: Could not connect to server
command terminated with exit code 7

In addition, Under ambient mirror related config is also issued, but will not take effect as well.

Further research is needed.