feat: add ability to restrict required-probes constraint to containers in pods selected by a service#273
Conversation
69d2913 to
2810758
Compare
|
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. |
|
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 <k8s@trought.ca>
Co-authored-by: Jaydipkumar Arvindbhai Gabani <gabanijaydip@gmail.com> Signed-off-by: Craig Trought <k8s@trought.ca>
Signed-off-by: Craig Trought <k8s@trought.ca>
Signed-off-by: Craig Trought <k8s@trought.ca>
77cc8a2 to
f7ae6f9
Compare
Signed-off-by: Craig Trought <k8s@trought.ca>
maxsmythe
left a comment
There was a problem hiding this comment.
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.
seems like we have samples in artifacthub but not here? is that intended?
| 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.
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.
@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.
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 k8s@trought.ca
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