-
Notifications
You must be signed in to change notification settings - Fork 769
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
No Violations found after enabling audit-from-cache #2858
Comments
What do you mean by "pre-existing data"? Why are you interesting in using audit-from-cache? The main reason to use audit-from-cache is to limit the numbers of requests audit sends to the API server. Audit-from-cache simply tells audit to use the Informer cache, instead of asking the API server for all resources under audit. If this is your use case and it's not working as expected, can you please share an example of a |
Thanks for looking into it.
I mean validating based on audit cache(data.inventory). We want to validate if any of the new "Service" that we create would NOT be allowed if any of the existing "Service" in the cluster has same key:value pair in its annotation already.
Absolutely. That was clear.
I think the issue i am facing is misunderstood. Apologies, if that was not clear. Here it goes:
After audit-from-cache is enabled and with config as shared before:
To conclude, though gatekeeper acting as per enforcement policy but the Issue is, we are missing(POINT 6 Above) the information on the list of objects that violated the constraints(which was not the case before enabling audit-from-cache). |
Thanks for sharing the details. So seems the issue is with the imagepullpolicyconstraint constraint, and the unique service annotation is working fine. For the imagepullpolicyconstraint constraint, it’s a deny policy, can you please confirm that you have at lease one pod violating this currently running in the cluster? ie not all requests have been denied. |
Yes, all constraints working fine to either deny/warn. Total Violations information of the constraint is missing after audit-from-cache is enabled.
Yes, I can confirm. imagepullpolicyconstraint is just an example, we have few other constraints and run tests(has pods which covers policies which are violated and few are not) to capture the violated object names. |
From your config, it looks like you are not syncing pods:
If you want to see audit violations for pods and you want to use the To be clear, you do not need the |
Enabling --audit-from-cache is definitely not what we are looking for as we have constraints on all objects including pods, jobs etc.
Ah. That's the miss understanding from my side. Thanks. |
What steps did you take and what happened:
We have set of opa policies defined and all were validated without using audit-from-cache as we did not had the requirement to validate based on Pre-existed data.
All objects which do not respect policy were denied/warned and same was visible in audit report of respective constraint definition.
Sample:
I have recently enabled audit-from-cache to true and defined a new constrainttemplates which validates if a specific annotation already exists across all services in the cluster.
Config:
With above config and defining(not shared consdering not relevant here, can provide if needed) new constratintemplate
uniqueannotation
, was able to successfully restrict the object creation when any service attempts to go against the policy.Also, It does capture the violations on the new constraint that I defined.
However, the audit report of existing constraints do not capture the results on the violations anymore. But, it still restricts the creation of objects which are not as per polices.
Please note that I have enabled Sync only on Service kind because I do not want to use memory by filling audit cache of all other k8s objects(which I do not validate using PRE-EXISTING data as before in existing constrainttemplates).
I see that similar bug was reported before #2026
But, that seems to be about not seeing violation on the newly created constraint template, which in my case is working.
What did you expect to happen:
With the issue stated, opa gatekeeper still restricts(warn/deny) the objects during creation time, but it audit report which used to help me in the past about on which object has attempted to go against the policy is no longer possible now.
Expected: Constraints should still contain violation report info though audit from cache is enabled.
Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]
Environment:
kubectl version
): 1.24.11The text was updated successfully, but these errors were encountered: