Skip to content

Commit

Permalink
antctl support traceflow
Browse files Browse the repository at this point in the history
Fixed antrea-io#923
antctl traceflow is on remote mode, inside controller mode and inside agent mode.
It supports yaml and json output. It can return without retrieving results.

e.g.
```
$ antctl traceflow -S busybox0 -D busybox1
name: default-busybox0-to-default-busybox1
phase: Succeeded
source: default/busybox0
destination: default/busybox1
noderesults:
- node: antrea-linux-testbed7-2
  role: ""
  timestamp: 1595391265
  observations:
  - component: SpoofGuard
    componentinfo: ""
    action: Forwarded
    pod: ""
    dstmac: ""
    networkpolicy: ""
    ttl: 0
    translatedsrcip: ""
    translateddstip: ""
    tunneldstip: ""
  - component: Forwarding
    componentinfo: Output
    action: Delivered
    pod: ""
    dstmac: ""
    networkpolicy: ""
    ttl: 0
    translatedsrcip: ""
    translateddstip: ""
    tunneldstip: ""
```
  • Loading branch information
lzhecheng committed Jul 29, 2020
1 parent 11792b6 commit 5182fe4
Show file tree
Hide file tree
Showing 13 changed files with 600 additions and 16 deletions.
4 changes: 4 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -590,6 +592,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
4 changes: 4 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -590,6 +592,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
4 changes: 4 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -590,6 +592,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
4 changes: 4 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -590,6 +592,8 @@ rules:
- list
- update
- patch
- create
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/base/agent-rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ rules:
- list
- update
- patch
- create
- delete
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/base/controller-rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ rules:
- list
- update
- patch
- create
- delete
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
Expand Down
1 change: 1 addition & 0 deletions build/yamls/base/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ spec:
hostPath:
path: /var/log/antrea
type: DirectoryOrCreate

48 changes: 48 additions & 0 deletions docs/antctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ running in two different modes:
- [Dumping Pod network interface information](#dumping-pod-network-interface-information)
- [Dumping OVS flows](#dumping-ovs-flows)
- [OVS packet tracing](#ovs-packet-tracing)
- [Traceflow](#traceflow)

## Installation

Expand Down Expand Up @@ -313,3 +314,50 @@ result: |
Megaflow: recirc_id=0x54,eth,ip,in_port=1,nw_frag=no
Datapath actions: 3
```

### Traceflow

`antctl traceflow` command is used to start a traceflow and retrieve its result. After the
result is collected, the traceflow will be deleted. Users can also create a traceflow with
`kubectl`, but `antctl traceflow` offers a simpler approach.

The required options for this command
are `source` and `destination`, which consist of namespace and pod. The command supports
yaml and json output. If users want a non blocking operation, a option: `--wait=false` can
be added to start the traceflow without waiting for result. For sure, the deletion operation
will not be conducted. Besides, users can specify header protocol (ICMP, TCP and UDP) and
source/destination ports.

e.g.
```bash
$ antctl traceflow -S busybox0 -D busybox1
name: default-busybox0-to-default-busybox1
phase: Succeeded
source: default/busybox0
destination: default/busybox1
noderesults:
- node: antrea-linux-testbed7-2
role: ""
timestamp: 1595391265
observations:
- component: SpoofGuard
componentinfo: ""
action: Forwarded
pod: ""
dstmac: ""
networkpolicy: ""
ttl: 0
translatedsrcip: ""
translateddstip: ""
tunneldstip: ""
- component: Forwarding
componentinfo: Output
action: Delivered
pod: ""
dstmac: ""
networkpolicy: ""
ttl: 0
translatedsrcip: ""
translateddstip: ""
tunneldstip: ""
```
6 changes: 6 additions & 0 deletions pkg/antctl/antctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/vmware-tanzu/antrea/pkg/agent/apiserver/handlers/podinterface"
"github.com/vmware-tanzu/antrea/pkg/agent/openflow"
"github.com/vmware-tanzu/antrea/pkg/antctl/raw/supportbundle"
"github.com/vmware-tanzu/antrea/pkg/antctl/raw/traceflow"
"github.com/vmware-tanzu/antrea/pkg/antctl/transform/addressgroup"
"github.com/vmware-tanzu/antrea/pkg/antctl/transform/appliedtogroup"
"github.com/vmware-tanzu/antrea/pkg/antctl/transform/controllerinfo"
Expand Down Expand Up @@ -324,6 +325,11 @@ var CommandList = &commandList{
supportAgent: true,
supportController: true,
},
{
cobraCommand: traceflow.Command,
supportAgent: true,
supportController: true,
},
},
codec: scheme.Codecs,
}
Expand Down
Loading

0 comments on commit 5182fe4

Please sign in to comment.