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

Make webhooks configurable #1981

Closed
JimBugwadia opened this issue Jun 8, 2021 · 4 comments · Fixed by #2425
Closed

Make webhooks configurable #1981

JimBugwadia opened this issue Jun 8, 2021 · 4 comments · Fixed by #2425
Assignees
Labels
enhancement New feature or request

Comments

@JimBugwadia
Copy link
Member

Is your feature request related to a problem? Please describe.

Currently Kyverno auto-creates and updates the validating and mutating webhooks, and user changes will be overwritten.

Describe the solution you'd like

Users should be allowed to tune the webhook configurations for their deployments.

Resource filters (currently set via args and configmap) should be applied to the webhook settings, to optimize which requests are handled by Kyverno.

Users should be able to migrate to failurePolicy=fail from failurePolicy=ignore.

Additional context

See slack discussions:

https://kubernetes.slack.com/archives/CLGR9BJU9/p1623155044256500

https://kubernetes.slack.com/archives/CLGR9BJU9/p1622078250126000

Also see: #893

@JimBugwadia JimBugwadia added the enhancement New feature or request label Jun 8, 2021
@yanniszark
Copy link

yanniszark commented Jun 10, 2021

Pasting an idea here from Kubernetes slack: https://kubernetes.slack.com/archives/CLGR9BJU9/p1623155044256500

Instead of letting users figure out the correct filter, why not continuously autogenerate it in the kyverno controller based on the currently existing policies? This ensure the filter is continuously optimal. More specifically:

  • For resource selector, this is very straightforward, just compile a list of (apiVersion, kind) used by policies in the cluster.
  • For namespace selector, this is not straightforward since Kyverno supports wildcard matching, which K8s does not.
    • We could compile a list of namespaces by running every policy's namespace selector regex against all existing namespaces. We would have to reason about the time it takes.
  • For object selector, this is not straightforward since Kyverno supports wildcard matching, which K8s does not.
    • We could follow the same tactic I mentioned for the namespace, but I think it gets prohibitively expensive at this point.

TLDR, implementing just the first bullet would be a huge improvement over the current state.
It would also make it easier to migrate to failurePolicy=fail, since only the availability of APIs appearing in Kyverno policies would be affected.

@chipzoller
Copy link
Member

I also support @yanniszark idea in the above comment. The webhook should be dynamically composed based upon the subjects of the policies under it. If a user only has policies created which apply to Service resources, the webhook should only be configured to send Service AdmissionReviews to Kyverno. Etc.

@diranged
Copy link

Seconding this bit:

Resource filters (currently set via args and configmap) should be applied to the webhook settings, to optimize which requests are handled by Kyverno.

We have run into a dozen situations or more where Kyverno was not in a good state and normal cluster operations could not succeed because of the failing webhooks.

@realshuting
Copy link
Member

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.

5 participants