Antrea-native policies should support appliedTo on a per rule basis #1327
Labels
area/network-policy/api
Issues or PRs related to the network policy API.
kind/design
Categorizes issue or PR as related to design.
Milestone
Describe what you are trying to solve
Antrea NetworkPolicy CRDs like ACNP and ANP supports enforcing ingress/egress policies on workloads specified in the
appliedTo
field in the policy spec. However, cluster admins are often posed with the need to create policy that needs to be enforced on different workloads, but serve the same purpose. For instance, consider web and db instances running in four namespaces,web-1
,web-2
,db-1
anddb-2
. An admin user might want to create policy that denies ingress traffic fromweb-1
todb-2
, and fromweb-2
todb-1
. Since the rules need to be enforced on two distinct set of workloads (pods indb-1
and pods indb-2
), user will need to create two separate Antrea-native policies (ACNP or CNP) for those two rules, while logically those rules should be grouped together instead.Describe the solution you have in mind
Include a
appliedTo
field in ANP and ACNP "to/from" rules such that users can set whom this rule applies to on a per rule basis. This field however should not be set in conjunction with theappliedTo
field in the policy spec. i.e. user can eitherappliedTo
in the policy spec section, without specifyingappliedTo
in any of the ingress/egress rules, orappliedTo
in each and every one of the ingress/egress rules defined in the policy, without settingappliedTo
in the policy spec section. Validation needs to be done to ensure this.As such, the rules mentioned in the section above can now be grouped into one policy:
Describe how your solution impacts user flows
This change will not impact existing policies or rules where
appliedTo
is set in the policy spec section, as this will continue to be supported. When creating new ACNP and ANPs, user will be able to define the policy in either 1) or 2) format as mentioned in the section above.Describe the main design/architecture of your solution
To be added.
The text was updated successfully, but these errors were encountered: