In the basic example of the documentation for declaring a network policy: https://kubernetes.io/docs/concepts/services-networking/network-policies/#the-networkpolicy-resource
So this sets several rules, as per the documentation:
So, the example NetworkPolicy:
- isolates “role=db” pods in the “default” namespace for both ingress
and egress traffic (if they weren’t already isolated)
- allows connections to TCP port 6379 of “role=db” pods in the “default”
namespace from any pod in the “default” namespace with the
label “role=frontend”
- allows connections to TCP port 6379 of “role=db” pods
in the “default” namespace from any pod in a namespace with
the label “project=myproject”
...
Does this means that the pods of "role=db" label can receive connections from:
Thanks!
Network policies can be viewed as rules. Each rule has a set of conditions and settings. NPS compares the conditions of the rule to the properties of connection requests. If a match occurs between the rule and the connection request, the settings defined in the rule are applied to the connection.
NetworkPolicy is stateful and will allow an established connection to communicate both ways.
If you want to control traffic flow at the IP address or port level (OSI layer 3 or 4), NetworkPolicies allow you to specify rules for traffic flow within your cluster, and also between Pods and the outside world. Your cluster must use a network plugin that supports NetworkPolicy enforcement.
Canal. If you want to use Flannel for networking but you need to define some network policies, yo can do it with Canal. The Canal means you're using Calico for policy and flannel for networking. For more details check Project Calico documentation.
The kubernetes network recipe "ALLOW traffic from apps using multiple selectors" is clear:
- Rules specified in
spec.ingress.from
are OR'ed.- This means the pods selected by the selectors are combined are whitelisted altogether.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With