-
Notifications
You must be signed in to change notification settings - Fork 390
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
netpolicy logs should also log drops from standard k8s netpol rules #3640
Comments
@Dyanngg I feel this may not be a good first issue. I have some questions:
|
Hi @tnqn ,
799-default-deny is a ANCP for block all and it has logging enabled, so it would be expected by the user being able to see all traffic dropped logged someplace.
But since default-deny-all is a standard k8s net policy that isolates the pod I can not see what connections are being attempted and blocked on /var/log/antrea/networkpolicy/np.log. maybe traceflow can help, but still it would be better to see that as an entry in the logs. |
Getting back to this. Traceflow is not a nice replacement for logs in anp.log |
Hi @tnqn, I completely agree with the issue described by @jsalatiel here, and their responses to your questions. Background:
Configuration tested: Antrea ClusterNetworkPolicy (ACNP) to drop and log all traffic associated with baseline Tier:
Kubernetes NetworkPolicy (KNP) objects in the namespace select the pods under test (making them KNP-isolated pods):
Tests on pod traffic show traffic is dropped (client programs time out), but np.log does not include any related messages. If I remove labels from a pod under test so that none of the KNPs select it, traffic is dropped and np.log shows drop events for the ACNP:
I also wanted to point out that this test is without any "default-deny-all" KNP like the case shown by @jsalatiel. The test has no KNP like default-deny-all selecting every pod. All it takes is one KNP selecting a pod, to make it isolated by KNP, and then the denies/drops for that pod will be done by Antrea's KNP mechanism only, and Antrea appears to be unable to log those drops to np.log. Exactly as stated in the issue title, Antrea should be able to log dropped traffic for pods isolated by KNP. Even though the drop is implicit by KNP's design, and, as @tnqn pointed out, is not tied to a specific KNP object, there will be teams that need to be informed of that dropped traffic, via the log (np.log). The logging might capture dropped traffic for pods not isolated by KNP, which might cover a spurious pod that was not intended by the development team. But the traffic with these "known" pods that are covered in the KNP is also still of interest - if the pods are behaving unexpectedly or used unexpectedly, those events are important. Unless those drops can be logged, there's almost no benefit to Antrea's logging feature, for organizations using KNP. |
About configuring the proposed logging behavior for Kubernetes NetworkPolicies/KNPs - since the NetworkPolicies within a namespace are evaluated collectively when deciding whether a pod is isolated by KNP, maybe the configuration is something that makes sense per namespace? Some options:
Options like these might also make configuration easier for users who are using Antrea as part of a pre-packaged solution like VMware's vSphere with Tanzu. VMware doesn't support users changing the Antrea configuration (the antrea-config-xxx ConfigMap) for this product. Users can only add new Antrea-type resources via the Antrea CRDs. |
/cc @antoninbas @jianjuns |
I think that this is a legitimate ask. The idea of adding an Antrea-specific Namespace annotation to toggle logging for K8s NetworkPolicies in that Namespace is interesting IMO. |
Is it the reasoning that - users prefer to use K8s NetworkPolicy (which they are more familiar with) over AntreaNetworkPolicy, but they are willing to learn the new annotation? |
Afaik , the annotation is created by the cluster admins. The KNP by the devs. |
Was thinking about that too, which makes more sense to me. + @yfauser to see if he has an opinion. |
That's exactly what I was thinking, too. It could allow a separation of duties like with the Namespace labels used by Pod Security Admission ( |
@jsalatiel @jdoylei thanks for the explanation. Now I understand the requirement is to log unintended access. The requirement and the proposal that uses a namespace annotation to control the behavior make sense to me. If everyone is on the same page, @qiyueyao could you evaluate the change and see which release we can add the support? |
@jsalatiel @jdoylei @jianjuns @tnqn @Dyanngg thanks for the proposal and discussion. Had a question regarding admission for the two methods
If this namespace annotation still sounds good, we can proceed further. Thanks. Doc for tracking this issue change. |
I think Namespace annotation should work. |
annotation is fine |
@qiyueyao - The namespace annotation sounds fine to me, even without Antrea itself enforcing who can or can't create the annotation. I think organizations deploying a cluster with Antrea could still choose one or both of these options outside of Antrea:
Thanks! |
Closed by #4047, audit logging support for K8s NetworkPolicy will be available in v1.8.0. |
As the cluster admin, I use antrea ACNP to define global rules and one last rule "default deny" policy with logging:
This way all drops are logged to /var/log/antrea/networkpolicy/np.log.
The developers are the ones responsible for building the netpolicies ( standard k8s netpolicies) for their appications as long as those do not conflict with the global rules defined in ANCP. The problem is that as soon their netpol is applied, the selected pods will not log anything on /var/log/antrea/networkpolicy/np.log.
In calico If i define a global logging. every DROP will be logged ( as a iptables LOG target in syslog ) even if the pod has been isolated by standard netpolicies. This global logging behaviour helps a lot debugging mainly when the developer forgets some allow rule. It would be nice if antrea could also log DROPs caused by pod isolation in standard k8s netpol.
Describe the solution you'd like
Add some global parameter to the agent, for example "LogStandardNetpolDrops" that will also log all drops from isolated pods to /var/log/antrea/networkpolicy/np.log. This is one of the main problems I see to debug developers' net policies when new deployments are not workind as expected.
The text was updated successfully, but these errors were encountered: