antrea-io / antrea

Kubernetes networking based on Open vSwitch
https://antrea.io
Apache License 2.0
1.67k stars 370 forks source link

antctl traceflow doesn't work for traffic to service #1126

Closed yktsubo closed 4 years ago

yktsubo commented 4 years ago

Describe the bug antctl traceflow doesn't work for destination service.
The injected packet is not processed as packets to service(clusterip) in ovs pipeline.

$ antctl traceflow -S elearning/rating-88bd94c44-xz4cf -D elearning/course -f tcp,tcp_dst=80
name: elearning-rating-88bd94c44-xz4cf-to-elearning-course-dx8p4szf
phase: Succeeded
source: elearning/rating-88bd94c44-xz4cf
destination: elearning/course
results:
- node: k8s3-node01
  timestamp: 1597917738
  observations:
  - component: SpoofGuard
    action: Forwarded
  - component: NetworkPolicy
    componentInfo: EgressDefaultRule
    action: Dropped

To Reproduce Do antctl traceflow for traffic to service like below.

$ antctl traceflow -S elearning/rating-88bd94c44-xz4cf -D elearning/course -f tcp,tcp_dst=80
name: elearning-rating-88bd94c44-xz4cf-to-elearning-course-dx8p4szf
phase: Succeeded
source: elearning/rating-88bd94c44-xz4cf
destination: elearning/course
results:
- node: k8s3-node01
  timestamp: 1597917738
  observations:
  - component: SpoofGuard
    action: Forwarded
  - component: NetworkPolicy
    componentInfo: EgressDefaultRule
    action: Dropped

Expected The injected packet is loadbalanced and delivered to the pod. Based on analysis with @gran-vmv , the following flag must be set to 2 when traffic is sent out to service.

transportHeader:
      tcp:
        srcPort: xx
        dstPort: xx
        flags: 2

Then It should work like below.

$ k get tf elearning-rating-to-elearning-course-svc -o yaml
apiVersion: ops.antrea.tanzu.vmware.com/v1alpha1
kind: Traceflow
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"ops.antrea.tanzu.vmware.com/v1alpha1","kind":"Traceflow","metadata":{"annotations":{},"name":"elearning-rating-to-elearning-course-svc"},"spec":{"destination":{"namespace":"elearning","service":"course"},"packet":{"ipHeader":{"protocol":6},"transportHeader":{"tcp":{"dstPort":80,"flags":2,"srcPort":10002}}},"source":{"namespace":"elearning","pod":"rating-88bd94c44-xz4cf"}}}
  creationTimestamp: "2020-08-20T11:21:00Z"
  generation: 1
  managedFields:
  - apiVersion: ops.antrea.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:spec:
        .: {}
        f:destination:
          .: {}
          f:namespace: {}
          f:service: {}
        f:packet:
          .: {}
          f:ipHeader:
            .: {}
            f:protocol: {}
          f:transportHeader:
            .: {}
            f:tcp:
              .: {}
              f:dstPort: {}
              f:flags: {}
              f:srcPort: {}
        f:source:
          .: {}
          f:namespace: {}
          f:pod: {}
    manager: kubectl
    operation: Update
    time: "2020-08-20T11:21:00Z"
  - apiVersion: ops.antrea.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        .: {}
        f:dataplaneTag: {}
        f:phase: {}
        f:results: {}
    manager: antrea-controller
    operation: Update
    time: "2020-08-20T11:21:05Z"
  name: elearning-rating-to-elearning-course-svc
  resourceVersion: "528512"
  selfLink: /apis/ops.antrea.tanzu.vmware.com/v1alpha1/traceflows/elearning-rating-to-elearning-course-svc
  uid: e2252307-c3d6-4407-b251-1ff92f77ded1
spec:
  destination:
    namespace: elearning
    service: course
  packet:
    ipHeader:
      protocol: 6
    transportHeader:
      tcp:
        dstPort: 80
        flags: 2
        srcPort: 10002
  source:
    namespace: elearning
    pod: rating-88bd94c44-xz4cf
status:
  dataplaneTag: 1
  phase: Succeeded
  results:
  - node: k8s3-node01
    observations:
    - action: Forwarded
      component: SpoofGuard
    - action: Forwarded
      component: LB
      pod: elearning/course-6576dc8cb4-rg6w4
      translatedDstIP: 172.29.2.46
    - action: Forwarded
      component: NetworkPolicy
      componentInfo: IngressRule
      networkPolicy: /course-api
    - action: Delivered
      component: Forwarding
      componentInfo: Output
    timestamp: 1597922465

Actual behavior The injected packet is not processed as packets to service(clusterip) in ovs pipeline.

Versions: Please provide the following information:

Additional context Add any other context about the problem here, such as Antrea logs, kubelet logs, etc.

(Please consider pasting long output into a GitHub gist or any other pastebin.)

yktsubo commented 4 years ago

FYI, this issue exists in Octant plugin.

yktsubo commented 4 years ago

@lzhecheng , Thank you!