-
Notifications
You must be signed in to change notification settings - Fork 321
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: add ability to restrict required-probes constraint to containers in pods selected by a service #273
feat: add ability to restrict required-probes constraint to containers in pods selected by a service #273
Conversation
library/general/requiredprobes/samples/must-have-probes/constraint.yaml
Outdated
Show resolved
Hide resolved
69d2913
to
2810758
Compare
...equiredprobes/1.1.0/samples/must-have-probes-on-service/example_disallowed_with_service.yaml
Outdated
Show resolved
Hide resolved
...equiredprobes/1.1.0/samples/must-have-probes-on-service/example_allowed_without_service.yaml
Outdated
Show resolved
Hide resolved
...equiredprobes/1.1.0/samples/must-have-probes-on-service/example_disallowed_with_service.yaml
Show resolved
Hide resolved
...acthub/library/general/requiredprobes/1.1.0/samples/must-have-probes/example_disallowed.yaml
Show resolved
Hide resolved
Few nits, but otherwise LGTM |
@ctrought thanks for the PR! Looks like there are conflicts, can you resolve when you get a chance? |
2128239
to
8d9bd22
Compare
8d9bd22
to
6f4b8ec
Compare
Thanks @sozercan , sorry for the delay.. I've resolved the merge conflicts. |
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
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 the contribution @ctrought - When you get a chance, I think there are just a few very minor open items above. |
…s in pods selected by a service Signed-off-by: Craig Trought <[email protected]>
Co-authored-by: Jaydipkumar Arvindbhai Gabani <[email protected]> Signed-off-by: Craig Trought <[email protected]>
Signed-off-by: Craig Trought <[email protected]>
Signed-off-by: Craig Trought <[email protected]>
77cc8a2
to
f7ae6f9
Compare
Signed-off-by: Craig Trought <[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.
Rego code and idea LGTM (did not look at rest of PR structure, tests, etc., relying on other reviewers there)
@@ -8,5 +8,6 @@ spec: | |||
- apiGroups: [""] |
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.
seems like we have samples in artifacthub but not here? is that intended?
@@ -4,7 +4,17 @@ metadata: | |||
name: k8srequiredprobes | |||
annotations: | |||
metadata.gatekeeper.sh/title: "Required Probes" | |||
metadata.gatekeeper.sh/version: 1.0.0 | |||
metadata.gatekeeper.sh/version: 1.1.0 | |||
metadata.gatekeeper.sh/requires-sync-data: | |
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.
To clarify a bit around the UX, with the onlyServices
parameter, it seems syncing service is optional, however does this annotation make syncing service a requirement?
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.
@apeabody this is a good question. How do we deal with conditionally referential templates? Should we just have a separate template, instead?
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.
Creating a separate template is an option, although I believe our goal should be to minimize the overall quantity of templates.
The current release Gatekeeper doesn't enforce requires-sync-data
, and unmarshaling of the annotation was only added in v3.13.0-beta.1. Depending on the roadmap, this might not be a blocker if the future plan was only to add a warning by default if the "required" sync wasn't configured in gatekeeper?
Per today's community call, adding the requires-sync-data annotation to an existing template is a breaking change. The decision is to create a new template @ctrought Can you please update this PR based on ^ Thank you! |
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Signed-off-by: Craig Trought [email protected]
What this PR does / why we need it:
Adds a parameter to restrict enforcement of the constraint to containers in pods that are selected by a service with at least one matching targetPort. For workloads that do not accept incoming traffic in pods it's common to not have readiness probes. This will allow the user to avoid generating violations for pods that do not accept incoming traffic via services. To leverage this services must be cached. This is a non-breaking change as the original implementation without caching is still supported by omitting the new parameter.
Adds a parameter to set an optional custom violation string that is appended to the standard one. I can revert this if it's not desired for the library, but we like to tailor certain violation messages with additional context so having the ability to do that in the constraint itself provides us the flexibility to do that without needing to alter the constraint template itself.
Removes the pod name from the violation message to avoid issues with expanded objects that likely won't contain a name. Seen in open-policy-agent/gatekeeper#2485