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 4 commits 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
202 changes: 202 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,202 @@
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: .status.phase
description: The phase of the PacketCapture.
name: Phase
type: string
- 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.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:
- fileServer
- source
- captureConfig
- destination
anyOf:
- properties:
source:
required: [pod]
- properties:
destination:
required: [pod]
properties:
source:
type: object
nullable: true
oneOf:
- required:
- pod
- required:
- ip
properties:
pod:
type: object
properties:
namespace:
type: string
name:
type: string
ip:
type: string
oneOf:
- format: ipv4
- format: ipv6
destination:
type: object
nullable: true
oneOf:
- required:
- pod
- required:
- ip
- required:
- service
properties:
pod:
type: object
properties:
namespace:
type: string
name:
type: string
service:
type: object
properties:
namespace:
type: string
name:
type: string
ip:
type: string
oneOf:
- format: ipv4
- format: ipv6
packet:
type: object
properties:
Comment on lines +113 to +115
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, IPv6]
default: IPv4
protocol:
x-kubernetes-int-or-string: true
transportHeader:
type: object
nullable: true
oneOf:
- required:
- tcp
- required:
- udp
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
flags:
type: integer
minimum: 0
maximum: 255
timeout:
type: integer
minimum: 1
maximum: 300
default: 60
captureConfig:
type: object
anyOf:
- properties:
firstN:
required: [number]
properties:
firstN:
type: object
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:
reason:
type: string
phase:
type: string
startTime:
type: string
numCapturedPackets:
type: integer
packetsFileName:
type: string
subresources:
status: {}
scope: Cluster
names:
plural: packetcaptures
singular: packetcapture
kind: PacketCapture
shortNames:
- pcap
182 changes: 182 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,188 @@ 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: .status.phase
description: The phase of the PacketCapture.
name: Phase
type: string
- 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.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:
- fileServer
- source
- captureConfig
- destination
anyOf:
- properties:
source:
required: [pod]
- properties:
destination:
required: [pod]
properties:
source:
type: object
properties:
pod:
type: string
namespace:
type: string
ip:
type: string
oneOf:
- format: ipv4
- format: ipv6
destination:
type: object
properties:
pod:
type: string
service:
type: string
namespace:
type: string
ip:
type: string
oneOf:
- format: ipv4
- format: ipv6
packet:
type: object
properties:
ipHeader:
type: object
properties:
protocol:
type: integer
minimum: 0
maximum: 255
ipv6Header:
type: object
properties:
nextHeader:
type: integer
minimum: 0
maximum: 65535
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
flags:
type: integer
minimum: 0
maximum: 255
timeout:
type: integer
minimum: 1
maximum: 300
captureConfig:
type: object
anyOf:
- properties:
firstN:
required: [number]
properties:
firstN:
type: object
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:
reason:
type: string
phase:
type: string
startTime:
type: string
numCapturedPackets:
type: integer
packetsFileName:
type: string

subresources:
status: {}
scope: Cluster
names:
plural: packetcaptures
singular: packetcapture
kind: PacketCapture
shortNames:
- pcp

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