Skip to content

Commit

Permalink
Add source ports in policy API (antrea-io#4687)
Browse files Browse the repository at this point in the history
This commit adds two optional fields, namely 'sourcePort' and
'sourceEndPort' to the NetworkPolicyPort definition of Antrea-native
policies.
When specified, the policy rule will only match traffic initiated
from a specific port (if only sourcePort is provided) or from a
specific port range (if both sourcePort and sourceEndPort are
provided). Supported protocols are TCP, UDP and SCTP.

Signed-off-by: Dyanngg <dingyang@vmware.com>
  • Loading branch information
Dyanngg authored and ceclinux committed May 30, 2023
1 parent 9cf3152 commit d29afe1
Show file tree
Hide file tree
Showing 33 changed files with 900 additions and 275 deletions.
8 changes: 8 additions & 0 deletions build/charts/antrea/crds/clusternetworkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -472,6 +476,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
8 changes: 8 additions & 0 deletions build/charts/antrea/crds/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -381,6 +385,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -850,6 +854,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1713,6 +1721,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1932,6 +1944,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -843,6 +847,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1694,6 +1702,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1913,6 +1925,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -850,6 +854,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1713,6 +1721,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1932,6 +1944,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -850,6 +854,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1713,6 +1721,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1932,6 +1944,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -850,6 +854,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1713,6 +1721,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1932,6 +1944,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
16 changes: 16 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -850,6 +854,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1713,6 +1721,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down Expand Up @@ -1932,6 +1944,10 @@ spec:
x-kubernetes-int-or-string: true
endPort:
type: integer
sourcePort:
type: integer
sourceEndPort:
type: integer
protocols:
type: array
items:
Expand Down
Loading

0 comments on commit d29afe1

Please sign in to comment.