-
Notifications
You must be signed in to change notification settings - Fork 790
Gatekeeper fails to start with mutation-webhook operation only - enforcement point error #3928
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
Comments
Our current working configuration under gatekeeper 3.15 that we want to continue to support:
To demonstrate a working gatekeeper 3.15 and non-working gatekeeper 3.18, I created a iximuiz devops playground to show case the deployments. Follow the instructions here: https://labs.iximiuz.com/playgrounds/my-custom-e733aca2-1848dc81 What you can do in the playgrounds:
ObservationsNo defect observed for Gatkeeper 3.15:
Defect observed for Gatekeeper 3.18
|
The error actually originates from this line in the Gatekeeper codebase: gatekeeper/vendor/github.com/open-policy-agent/frameworks/constraint/pkg/client/new_client.go Line 28 in 23fa58c
The OPA framework expects an enforcementPoint to be provided when initializing the client. Gatekeeper maps operations like webhook and audit to their corresponding enforcement points internally. So, if no operation (i.e., neither webhook nor audit) is specified, Gatekeeper attempts to initialize the OPA client without any enforcement points—causing the failure. Enforcement points are used by the framework to associate constraints with incoming review requests. This ensures that only constraints relevant to the specific enforcement point (e.g., audit or webhook) are evaluated. This mechanism is what enables use cases such as applying a particular constraint only during audit. There are three ways to fix it -
@ritazh I am curious to know your thoughts on what way we should lean towards. I prefer 3rd option which requires bigger change but optimizes the code a little bit as well since we do not need OPA client if we are not using operation |
Thanks for the summary @JaydipGabani I agree we should refactor GK and only use OPA client when needed as a long term solution, however this will require lots of code changes and testing to ensure backward compatibility and to prevent regressions. A change like that IMO isnt a patch release update. To remediate this issue soon and to get a patch release out soon with minimal code change to ensure we don't introduce more variables, I prefer option 2 since enforcement code should handle the case where enforcement points are not provided. |
Sounds good @JaydipGabani. I'll connect with you this week to detail out the scope of changes. I'm in the process of getting the gatekeeper project reviewed and approved with my firms open source contribution process. |
What steps did you take and what happened:
Using Gatekeeper 3.18.2 on Kubernetes 1.32 (also observed on 1.29), when the operation is set to mutation-webhook only (to isolate mutation operations), the following error occurs:
What did you expect to happen:
I expected the Gatekeeper instance to start running without any issues when the operation is set to mutation-webhook only.
Anything else you would like to add:
As a workaround, adding both mutation-webhook and webhook operation flags allows Gatekeeper to start successfully:
This suggests that Gatekeeper requires at least one enforcement point even when only mutation capabilities are needed.
Environment:
kubectl version
):The text was updated successfully, but these errors were encountered: