-
Notifications
You must be signed in to change notification settings - Fork 781
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
feat: Make gatekeeper validate subresources #2054
Conversation
Signed-off-by: Mac Chaffee <[email protected]>
Thanks for the PR and finding relevant subresources! The code LGTM. Should we also add it to the static manifest by updating this codegen comment: gatekeeper/pkg/webhook/policy.go Line 73 in 206bbe9
and running Or maybe filing a new issue? |
Hmm forgot about the static manifests. @ritazh 's comment about this changing the default behavior might be more applicable to the static manifest since people might install straight off the master branch. I still lean towards "yes, change the default to cover subresources", but we should definitely mention it prominently in the patch notes. Are we on the same page there? |
Another thought is @mac-chaffee What kind of performance impact would this change have if we add all the other subresources by default? |
@ritazh I'd expect the performance impact to be minimal since subresources are almost always called less-frequently than the parent resource (which gatekeeper already validates). I could imagine a handful of users who might call If you all are feeling anxious about this change, I think these are our options:
|
IMO I'm for enforce everywhere by-default (warning the user via release notes). In general, I think loud failures are easier to spot and mitigate than silent ones. |
@maxsmythe I was thinking the same thing about loud vs. quiet failures 😁 Sounds good, I can get the static manifests updated tomorrow |
Signed-off-by: Mac Chaffee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding these subresources! LGTM
Looks like someone made a script to get these subresources here: https://stackoverflow.com/a/51289417 Here's a slightly modified version to dump these in case there are any added in the future:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #2054 +/- ##
==========================================
+ Coverage 54.34% 54.50% +0.16%
==========================================
Files 111 111
Lines 9470 9470
==========================================
+ Hits 5146 5162 +16
+ Misses 3933 3921 -12
+ Partials 391 387 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Do we want to cut another release to bump the chart version? @sozercan @maxsmythe |
@ritazh v3.9.0-beta.2? |
sgtm |
@@ -119,6 +119,24 @@ var replacements = map[string]string{ | |||
{{- end }} | |||
resources: | |||
- '*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this "*" need to come out of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the star refers to all non-sub-resources. For example "configmaps" or "secrets" or "pods". We still definitely want to trigger validation on those like we have done historically.
This PR does not reduce the amount of resources that gatekeeper validates; it expands that list to cover subresources.
Co-authored-by: Sertaç Özercan <[email protected]> Signed-off-by: davis-haba <[email protected]>
What this PR does / why we need it:
Gatekeeper's validatingwebhook is currently configured to match
'*'
, which doesn't include subresources. There has been scattered discussion around adding subresources to the validatingwebhook, but nothing conclusive, probably due to the fact that a complete list of subresources doesn't really exist.I was able to get a really good list of subresources by searching the Kubernetes codebase for
Subresource("
, which I've included in this PR. However, in my testing, intercepting thestatus
subresource causes cluster instability (it's very high-traffic, and you can't smoothly roll out new policies to pods because the old pods trigger validation upon deletion since the status field updates). So we can't just specify'*/*'
.Which issue(s) this PR fixes
Related to #1087, #45, #1056, and open-policy-agent/gatekeeper-library#188
Fixes #1837
Special notes for your reviewer:
cc @srenatus , mentioned this here but seems this issue about subresources is already public (according to those issues I linked above and the slack convo on May 17th)