generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The following is a question and should be treated as such
Policy enforcement in the code
- For the destination Service ClusterIP to be whitelisted by a NetworkPolicy the requirements is that the set of labels in the
.spec.selectorin the Service definition ALL match with the set of labels in the.spec.egress[].to[].podSelector.matchLabels(of theNetworkPolicy) (code) - If the NetworkPolicy lists ports on which traffic is allowed, then in addition to the above requirement, the service Port must match with Container Port of the destination Pods. (code).
- The above item no. 2, also goes back to the last requirement for the NetworkPolicies. As an example, an UI pod can reach the Backend Pod on the containerPort: 8080 if the
NetworkPolicyallows/opens up the traffic on port 8080. But this packet transit won’t happen via the Backend Service if the port defined in the Service spec accepts traffic at port 80.
Can an alternate approach be used here?
Is the approach presented below possible? I can easily sense that the below logic, using pods, that can come in and go during scaling, may not be an ideal approach. But nevertheless, I am curious and request validation.
- Find all the pods that the
NetworkPolicycould potentially target using the selectors - Let’s call the list X - Find all the pods that the Service targets - Let’s call this list Y
- Whitelist the Service
ClusterIPif X ⊆ Y

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request