Skip to content
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

Add a flag for GK validating webhook to defer to vap #3331

Closed
ritazh opened this issue Mar 22, 2024 · 0 comments · Fixed by #3335
Closed

Add a flag for GK validating webhook to defer to vap #3331

ritazh opened this issue Mar 22, 2024 · 0 comments · Fixed by #3335
Labels
enhancement New feature or request
Milestone

Comments

@ritazh
Copy link
Member

ritazh commented Mar 22, 2024

Describe the solution you'd like
[A clear and concise description of what you want to happen.]

Add flag --webhook-defers-to-vap. default to false. Defaulting to false so that GK webhook can act as a fallback in case vap fails. However, for allow cases, it will result in extra CPU usage from the webhook.

If false, vapDefault for the vap driver in constraint framework is nil. when vapDefault is nil, use-vap label cannot override the behavior.
if true, then set vapDefault to VAPDefaultNo such that the use-vap label on constraint template and constraints can override the behavior.

Note: After reviewing the k8s apiserver code, the admission plugins are processed in a somewhat predictable order, see https://github.com/kubernetes/kubernetes/blob/20d0ab7ae808aaddb1556c3c38ca0607663c50ac/staging/src/k8s.io/apiserver/pkg/admission/chain.go#L46-L55 This means the vap plugin should be processed before any of the webhooks and if there's an error, it will return immediately without hitting any of the subsequent plugins.
From https://github.com/kubernetes/kubernetes/blob/20d0ab7ae808aaddb1556c3c38ca0607663c50ac/pkg/kubeapiserver/options/plugins.go#L97-L102 the comment suggests webhook, resourcequota, and deny plugins should always go last. Technically the order could be changed but it is probably unlikely. We have open-policy-agent/frameworks#400 in framework, but default to nil so use-vap labels cannot override the behavior such that GK can act as a fallback. However, this does mean extra cpu overhead for the successful requests. We will continue to monitor this to determine a good default to set in GK.

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Gatekeeper version:
  • Kubernetes version: (use kubectl version):
@ritazh ritazh added the enhancement New feature or request label Mar 22, 2024
@ritazh ritazh added this to the v3.16.0 milestone Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant