Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Hang Yan <yhang@vmware.com>
  • Loading branch information
hangyan committed Jan 8, 2024
1 parent 0d665c3 commit dbb59ea
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 10 deletions.
3 changes: 3 additions & 0 deletions build/charts/antrea/conf/antrea-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ featureGates:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "Traceflow" "default" true) }}

# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "PacketSampling" "default" false) }}

# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "NodePortLocal" "default" true) }}

Expand Down
3 changes: 3 additions & 0 deletions build/charts/antrea/conf/antrea-controller.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ featureGates:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "Traceflow" "default" true) }}

# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "PacketSampling" "default" false) }}

# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down
10 changes: 8 additions & 2 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5749,6 +5749,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
# NodePortLocal: true
Expand Down Expand Up @@ -6151,6 +6154,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down Expand Up @@ -7134,7 +7140,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: fe9081d7718e258905728726bb8f3a8d42a332d7f4e0d8faaa9731b3c4b51aa4
checksum/config: a56d0e6f4fb9e61c024376117a1b918a4124cdeef0a9d10c711902da92817a2d
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -7372,7 +7378,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: fe9081d7718e258905728726bb8f3a8d42a332d7f4e0d8faaa9731b3c4b51aa4
checksum/config: a56d0e6f4fb9e61c024376117a1b918a4124cdeef0a9d10c711902da92817a2d
labels:
app: antrea
component: antrea-controller
Expand Down
10 changes: 8 additions & 2 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5749,6 +5749,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
# NodePortLocal: true
Expand Down Expand Up @@ -6151,6 +6154,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down Expand Up @@ -7134,7 +7140,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: fe9081d7718e258905728726bb8f3a8d42a332d7f4e0d8faaa9731b3c4b51aa4
checksum/config: a56d0e6f4fb9e61c024376117a1b918a4124cdeef0a9d10c711902da92817a2d
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -7373,7 +7379,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: fe9081d7718e258905728726bb8f3a8d42a332d7f4e0d8faaa9731b3c4b51aa4
checksum/config: a56d0e6f4fb9e61c024376117a1b918a4124cdeef0a9d10c711902da92817a2d
labels:
app: antrea
component: antrea-controller
Expand Down
10 changes: 8 additions & 2 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5749,6 +5749,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
# NodePortLocal: true
Expand Down Expand Up @@ -6151,6 +6154,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down Expand Up @@ -7134,7 +7140,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 997259cac105a193d671880b165e203a9954f33009766df5eceed753509c46b9
checksum/config: 86f952f61cb57c7c74681c1d2c96f0cd42c36a012f922fcfb08cccc0904a0865
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -7370,7 +7376,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 997259cac105a193d671880b165e203a9954f33009766df5eceed753509c46b9
checksum/config: 86f952f61cb57c7c74681c1d2c96f0cd42c36a012f922fcfb08cccc0904a0865
labels:
app: antrea
component: antrea-controller
Expand Down
10 changes: 8 additions & 2 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5762,6 +5762,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
# NodePortLocal: true
Expand Down Expand Up @@ -6164,6 +6167,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down Expand Up @@ -7147,7 +7153,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 4364ee1520a24d9a465a405536736498119269c0fc81d4dc01e83d7fdd462913
checksum/config: 3e90331f2f20c9f07ae16fc523acd9fbbe8b4a77000bc76ab3cec1e4e2d9bdb7
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
labels:
app: antrea
Expand Down Expand Up @@ -7429,7 +7435,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 4364ee1520a24d9a465a405536736498119269c0fc81d4dc01e83d7fdd462913
checksum/config: 3e90331f2f20c9f07ae16fc523acd9fbbe8b4a77000bc76ab3cec1e4e2d9bdb7
labels:
app: antrea
component: antrea-controller
Expand Down
10 changes: 8 additions & 2 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5749,6 +5749,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable NodePortLocal feature to make the Pods reachable externally through NodePort
# NodePortLocal: true
Expand Down Expand Up @@ -6151,6 +6154,9 @@ data:
# Enable traceflow which provides packet tracing feature to diagnose network issue.
# Traceflow: true
# Enable packetsampling feature which provides packets sampling(capture) feature to diagnose network issue.
# PacketSampling: false
# Enable Antrea ClusterNetworkPolicy feature to complement K8s NetworkPolicy for cluster admins
# to define security policies which apply to the entire cluster, and Antrea NetworkPolicy
# feature that supports priorities, ExternalEntities, FQDN rules and more.
Expand Down Expand Up @@ -7134,7 +7140,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: d8e5dd6cc4bd55eeba224229fd8207045291ab3dfafe5f3c3e100c31003d2887
checksum/config: 5d9fb06153619371fccc067e9c405ae2f6729b407fa49453692ada4acab742bc
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -7370,7 +7376,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: d8e5dd6cc4bd55eeba224229fd8207045291ab3dfafe5f3c3e100c31003d2887
checksum/config: 5d9fb06153619371fccc067e9c405ae2f6729b407fa49453692ada4acab742bc
labels:
app: antrea
component: antrea-controller
Expand Down
92 changes: 92 additions & 0 deletions docs/packetsampling-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# PacketSampling User Guide

Antrea supports using PacketSampling for network diagnosis. It can capture
specified number of packets from real traffic and upload them to a
supported storage location. Users can create a PacketSampling CRD to trigger
such an action on the target traffic flow.

## Prerequisites

The PacketSampling feature is disabled by default since Antrea 1.16.0. If you
want to enable this feature, you need to enable PacketSampling from the
featureGates map defined in antrea.yml fro both Controller and Agent. In
order to use a Service as the destination in sampling, you also need to ensure
[AntreaProxy](feature-gates.md) is enabled in the agent configuration:

```yaml
antrea-controller.conf: |
featureGates:
# Enable packetsampling feature to help diagnose network issues by capture real traffic packets.
PacketSampling: true
antrea-agent.conf: |
featureGates:
# Enable packetsampling feature to capture real traffic packets.
PacketSampling: true
# Enable AntreaProxy which provides ServiceLB for in-cluster Services in antrea-agent.
# It should be enabled on Windows, otherwise NetworkPolicy will not take effect on
# Service traffic.
AntreaProxy: true
```
## Start a new PacketSampling
When start a new sampling, you can provide the following information to identify
the target flow:
* source pod
* destination pod, Service or destination IP address
* transport protocol(TCP/UDP/ICMP)
* transport ports
You can start a new packet sampling by creating PacketSampling CRD via
`kubectl` and a yaml file which contains the essential configuration of
PacketSampling CRD. An example YAML file of PacketSampling CRD might
look like this:

```yaml
apiVersion: crd.antrea.io/v1alpha1
kind: PacketSampling
metadata:
name: ps-test
spec:
fileServer:
url: sftp://127.0.0.1:22/upload
authentication:
authType: "BasicAuthentication"
authSecret:
name: test-secret
namespace: default #
timeout: 600
type: FirstNSampling
firstNSamplingConfig:
number: 5
source:
namespace: default
pod: frontend
destination:
namespace: default
pod: backend
# destination can also be an IP address ('ip' field) or a Service name ('service' field); the 3 choices are mutually exclusive.
packet:
ipHeader: # If ipHeader/ipv6Header is not set, the default value is IPv4+ICMP.
protocol: 6 # Protocol here can be 6 (TCP), 17 (UDP) or 1 (ICMP), default value is 1 (ICMP)
transportHeader:
tcp:
dstPort: 8080 # Destination port needs to be set when Protocol is TCP/UDP.
```
The CRD above starts a new packet sampling from pod named `frontend`
to port 8080 of pod named `backend` using TCP protocol.

## RBAC
PacketSampling CRDs are meant for admins to troubleshoot and diagnose the network
by capture sampling packets from a source workload to a destination workload. Thus,
access to manage these CRDs must be granted to subjects which
have the authority to perform these diagnostic actions. On cluster
initialization, Antrea grants the permissions to edit these CRDs with `admin`
and the `edit` ClusterRole. In addition to this, Antrea also grants the
permission to view these CRDs with the `view` ClusterRole. Cluster admins can
therefore grant these ClusterRoles to any subject who may be responsible to
troubleshoot the network. The admins may also decide to share the `view`
ClusterRole to a wider range of subjects to allow them to read the packetsamplings
that are active in the cluster.

0 comments on commit dbb59ea

Please sign in to comment.