Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packetcapture api #6257

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 194 additions & 0 deletions build/charts/antrea/crds/packetcapture.yaml
hangyan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: packetcaptures.crd.antrea.io
labels:
app: antrea
spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: true
additionalPrinterColumns:
- jsonPath: .spec.source.pod
description: The name of the source Pod.
name: Source-Pod
type: string
priority: 10
- jsonPath: .spec.destination.pod
description: The name of the destination Pod.
name: Destination-Pod
type: string
priority: 10
- jsonPath: .spec.source.ip
description: The IP address of the source.
name: Source-IP
type: string
priority: 10
- jsonPath: .spec.destination.ip
description: The IP address of the destination.
name: Destination-IP
type: string
priority: 10
hangyan marked this conversation as resolved.
Show resolved Hide resolved
antoninbas marked this conversation as resolved.
Show resolved Hide resolved
- jsonPath: .spec.timeout
description: Timeout in seconds.
name: Timeout
type: integer
priority: 10
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
schema:
openAPIV3Schema:
type: object
required:
- spec
properties:
spec:
type: object
required:
- source
- captureConfig
- destination
anyOf:
- properties:
source:
required: [pod]
- properties:
destination:
required: [pod]
properties:
source:
type: object
oneOf:
- required:
- pod
- required:
- ip
properties:
pod:
type: object
required:
- name
properties:
namespace:
type: string
default: default
name:
type: string
ip:
type: string
format: ipv4
destination:
type: object
oneOf:
- required:
- pod
- required:
- ip
properties:
pod:
type: object
required:
- name
properties:
namespace:
type: string
default: default
name:
type: string
ip:
type: string
format: ipv4
packet:
type: object
properties:
Comment on lines +104 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like we are missing the srcIP / dstIP properties here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's actually not missed, since we have a Source and Destination field in spec, so the srcIP/dstIP is not used. The golang structure still keep these fields in the PR, but i think we can removed them. The whole Packet structure has changed a lot during the review compared to the original one(==Traceflow's Packet strucuture).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this part. Currently the package related structure looks like this:


// Packet includes header info.
type Packet struct {
	IPv6Header      *IPv6Header     `json:"ipv6Header,omitempty"`
	TransportHeader TransportHeader `json:"transportHeader"`
}

Note: remove IPv4Header as it's unused and in another thread, we are discussing if a IPFamily field is needed.

Also in the TransportHeader, we have tcp/icmp/udp strcuture to allow user filter based on transport attributes. For icmp, we don't have any filter yet, so the strucutre is mainly used as a type indicator.

type ICMPEchoRequestHeader struct {
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jianjuns @tnqn @luolanzone

Can you help review this MR again? Thank you

I will be actively working on this recently.

ipFamily:
type: string
enum: [IPv4]
default: IPv4
protocol:
x-kubernetes-int-or-string: true
hangyan marked this conversation as resolved.
Show resolved Hide resolved
transportHeader:
type: object
properties:
udp:
type: object
properties:
srcPort:
type: integer
minimum: 1
maximum: 65535
dstPort:
type: integer
minimum: 1
maximum: 65535
tcp:
type: object
properties:
srcPort:
type: integer
minimum: 1
maximum: 65535
dstPort:
type: integer
minimum: 1
maximum: 65535

timeout:
type: integer
minimum: 1
maximum: 300
default: 60
captureConfig:
type: object
oneOf:
- required:
- firstN
properties:
firstN:
type: object
required:
- number
properties:
number:
type: integer
format: int32
fileServer:
type: object
properties:
url:
type: string
pattern: 's{0,1}ftps{0,1}:\/\/[\w-_./]+:\d+'
status:
type: object
properties:
numberCaptured:
type: integer
filePath:
type: string
conditions:
type: array
items:
type: object
properties:
type:
type: string
status:
type: string
lastTransitionTime:
type: string
reason:
type: string
message:
type: string
subresources:
status: {}
scope: Cluster
names:
plural: packetcaptures
singular: packetcapture
kind: PacketCapture
shortNames:
- pcap
197 changes: 197 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,203 @@ spec:
shortNames:
- nlm

---
# Source: antrea/crds/packetcapture.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: packetcaptures.crd.antrea.io
labels:
app: antrea
spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: true
additionalPrinterColumns:
- jsonPath: .spec.source.pod
description: The name of the source Pod.
name: Source-Pod
type: string
priority: 10
- jsonPath: .spec.destination.pod
description: The name of the destination Pod.
name: Destination-Pod
type: string
priority: 10
- jsonPath: .spec.source.ip
description: The IP address of the source.
name: Source-IP
type: string
priority: 10
- jsonPath: .spec.destination.ip
description: The IP address of the destination.
name: Destination-IP
type: string
priority: 10
- jsonPath: .spec.timeout
description: Timeout in seconds.
name: Timeout
type: integer
priority: 10
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
schema:
openAPIV3Schema:
type: object
required:
- spec
properties:
spec:
type: object
required:
- source
- captureConfig
- destination
anyOf:
- properties:
source:
required: [pod]
- properties:
destination:
required: [pod]
properties:
source:
type: object
oneOf:
- required:
- pod
- required:
- ip
properties:
pod:
type: object
required:
- name
properties:
namespace:
type: string
default: default
name:
type: string
ip:
type: string
format: ipv4
destination:
type: object
oneOf:
- required:
- pod
- required:
- ip
properties:
pod:
type: object
required:
- name
properties:
namespace:
type: string
default: default
name:
type: string
ip:
type: string
format: ipv4
packet:
type: object
properties:
ipFamily:
type: string
enum: [IPv4]
default: IPv4
protocol:
x-kubernetes-int-or-string: true
transportHeader:
type: object
properties:
udp:
type: object
properties:
srcPort:
type: integer
minimum: 1
maximum: 65535
dstPort:
type: integer
minimum: 1
maximum: 65535
tcp:
type: object
properties:
srcPort:
type: integer
minimum: 1
maximum: 65535
dstPort:
type: integer
minimum: 1
maximum: 65535

timeout:
type: integer
minimum: 1
maximum: 300
default: 60
captureConfig:
type: object
oneOf:
- required:
- firstN
properties:
firstN:
type: object
required:
- number
properties:
number:
type: integer
format: int32
fileServer:
type: object
properties:
url:
type: string
pattern: 's{0,1}ftps{0,1}:\/\/[\w-_./]+:\d+'
status:
type: object
properties:
numberCaptured:
type: integer
filePath:
type: string
conditions:
type: array
items:
type: object
properties:
type:
type: string
status:
type: string
lastTransitionTime:
type: string
reason:
type: string
message:
type: string
subresources:
status: {}
scope: Cluster
names:
plural: packetcaptures
singular: packetcapture
kind: PacketCapture
shortNames:
- pcap

---
# Source: antrea/crds/supportbundlecollection.yaml
apiVersion: apiextensions.k8s.io/v1
Expand Down
Loading
Loading