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

feat(general): Add volumeresources emptyDir sizelimit #514

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

dongjiang1989
Copy link

What this PR does / why we need it:
feat(general): Add volumeresources emptyDir sizelimit.

one node in the cluster was emptyDirevicted because the log volume not set a capacity limit sizeLimit.

Which issue(s) does this PR fix (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #

Special notes for your reviewer:

@dongjiang1989 dongjiang1989 requested a review from a team as a code owner April 24, 2024 13:59
Signed-off-by: dongjiang1989 <[email protected]>
Signed-off-by: dongjiang1989 <[email protected]>
@JaydipGabani
Copy link
Contributor

@dongjiang1989 can you also modify empty suite.yaml with appropriate configurations? - here is an example of working suite.yaml - https://github.com/open-policy-agent/gatekeeper-library/blob/master/library/general/block-wildcard-ingress/suite.yaml

@dongjiang1989
Copy link
Author

@dongjiang1989 can you also modify empty suite.yaml with appropriate configurations? - here is an example of working suite.yaml - https://github.com/open-policy-agent/gatekeeper-library/blob/master/library/general/block-wildcard-ingress/suite.yaml

Thanks. @JaydipGabani
Fixed. Please re-check

Copy link
Contributor

@JaydipGabani JaydipGabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This policy will not work for Pod. Please modify constraint or rego.

@JaydipGabani
Copy link
Contributor

@dongjiang1989 appologies for going back and forth, but it would be best to keep the policy applicable to pods because currenlty library doesn't test policies with expansionTemplates and the CI will likely fail since you are using Deployment for allowed/disallowed examples, you would not get expected violations in return. The policy would still deny the pods spinned up by workload resouces as well, but the denied message wouldn't be in the stdout without expansionTemplate (the denied message could be found on status of the parent resource for the pod).

@dongjiang1989
Copy link
Author

@dongjiang1989 appologies for going back and forth, but it would be best to keep the policy applicable to pods because currenlty library doesn't test policies with expansionTemplates and the CI will likely fail since you are using Deployment for allowed/disallowed examples, you would not get expected violations in return. The policy would still deny the pods spinned up by workload resouces as well, but the denied message wouldn't be in the stdout without expansionTemplate (the denied message could be found on status of the parent resource for the pod).

Thanks @JaydipGabani . PTAL re-check

Keep the policy applicable to pods done.

@JaydipGabani
Copy link
Contributor

@dongjiang1989 you will need to remove examples with kind: Deployment from artifacthub/ dir.

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989
Copy link
Author

dongjiang1989 commented Jun 18, 2024

@dongjiang1989 you will need to remove examples with kind: Deployment from artifacthub/ dir.

@JaydipGabani Thanks for your review. Done.

Copy link
Contributor

@JaydipGabani JaydipGabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JaydipGabani
Copy link
Contributor

@maxsmythe @ritazh @sozercan PTAL.

- |
package lib.exempt_container

is_exempt(container) {
Copy link
Member

@ritazh ritazh Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is is_exempt used? might be good to also add an exemptImage example to the allowed test case

Copy link
Author

@dongjiang1989 dongjiang1989 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks.

apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: k8svolumerequests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this policy validates specifically for emptydir volume size limit, the name, description should be updated to reflect this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ritazh change name to k8semptydirvolumesizelimit?

@ritazh
Copy link
Member

ritazh commented Jun 27, 2024

Thanks for the PR!

Copy link

stale bot commented Nov 14, 2024

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.

@stale stale bot added the stale label Nov 14, 2024
@dongjiang1989
Copy link
Author

@ritazh @JaydipGabani Please re-check it, thanks

@stale stale bot removed the stale label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants