-
-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive on Network Policies .. Sometimes #311
Comments
This is maybe out of scope for this issue, and admittedly I'm still working on understanding Network Policies, but I'm struggling to understand the logic in Popeye on checking ingress/egress policies. If we get to this branch of code: Lines 119 to 126 in d09ec25
I'm not sure the logic in Lines 177 to 199 in d09ec25
If we have a NetworkPolicy which targets the pod in question, and it has ingress rules, Similarly for In other words, this seems to only pass when the NetworkPolicy says the pod can talk to itself. |
@bpfoster For the initial issue, this is indeed a problem. Will fix on the next drop. |
Fixes v0.21.5 |
I just had a similar thing come up when denying egress:
This is my NetworkPolicy
I did verify that the policy works by looking at the drops in Cilium. Am I missing something? |
I hadn't revisited this. I too am still getting (at least consistently now!) false positives on networkpolicy linting (on latest popeye v0.21.5). In my case, I get
For @siegy22 's example, playing around with some unit tests, changing
But I frankly don't know if the result is the same? |
@bpfoster Your example denies ingress and egress. My goal is to have any ingress and no egress. Which is defined by:
But popeye says there's no egress defined (which in theory is correct) but the effect is not the same as not defining it. |
Describe the bug
Running popeye sometimes reports
Despite there being a Network Policy for it.
Expected behavior
No warning on missing Network Policy
Versions (please complete the following information):
Additional context
I have created NetworkPolicies using the
resource type.
I notice the cluster also has Calico installed providing their NetworkPolicy CRD:
Installed policies:
When I debug popeye, I see that the GVR being queried in the DB for network policies is sometimes the calico one, and sometimes the k8s.io one.
popeye/internal/lint/pod.go
Line 96 in d09ec25
When it's the Calico one, the NetworkPolicy is not found.
My guess is there's some non-determinism in the order in which the CRDs are returned/loaded, and from what I can see, the popeye DB only supports 1 per type and is overwriting whichever comes first with the second one.
popeye/internal/alias.go
Lines 92 to 116 in d09ec25
Thinking about it... should popeye know the GVR for each resource type it cares about, and ignore others? In this case it knows it wants
networkpolicies.networking.k8s.io
and would discard the caclico type. If there was a calico NP (or some other random one), popeye would panic when it tries to assert tonetv1.NetworkPolicy
.The text was updated successfully, but these errors were encountered: