-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: enforce restricted Pod Security Context Compliance in testing #4435
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lunarwhite The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @lunarwhite. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
"spec": { | ||
"containers": [{ | ||
"name": "curl", | ||
"image": "curlimages/curl:7.87.0", |
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.
Instead of pinning a version, do you think we could use the latest to make it easier the code be maintained and we do not need to bump new versions
WDYT?
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.
Addressed. Ready for another review.
/ok-to-test |
Hi @lunarwhite Regards the CI errors: In this case it is failing in the API diff because we are changing it at
But we do not really need to support its utils Note that we have a plugin that scaffolds code to manage an image. We might consider enforcing tests only for The first step is to understand the error mentioned above. Additionally, ensure that the error string is being output correctly—it might currently be missing a conversion from |
@camilamacedo86 Thanks for your hints!
The readable output would be like:
Are you suggesting we should keep the By("deploying the controller-manager")
cmd := exec.Command("make", "deploy", "IMG="+kbc.ImageName)
++ out, err := kbc.Run(cmd)
++ Expect(string(output)).NotTo(ContainSubstring("Warning: would violate PodSecurity"))
-- Expect(kbc.Run(cmd)).NotTo(ContainSubstring("Warning: would violate PodSecurity")) Or just: By("deploying the controller-manager")
++ Expect(kbc.Make("deploy", "IMG="+kbc.ImageName)).To(Succeed())
-- cmd := exec.Command("make", "deploy", "IMG="+kbc.ImageName)
-- Expect(kbc.Run(cmd)).NotTo(ContainSubstring("Warning: would violate PodSecurity")) Both of them passed locally. |
We need to have
To get the output in the logs. |
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.
/ok-to-test
ea2dee6
into
kubernetes-sigs:master
@@ -93,7 +93,8 @@ func Run(kbc *utils.TestContext) { | |||
|
|||
By("deploying the controller-manager") | |||
cmd := exec.Command("make", "deploy", "IMG="+kbc.ImageName) | |||
Expect(kbc.Run(cmd)).NotTo(ContainSubstring("Warning: would violate PodSecurity")) | |||
out, _ := kbc.Run(cmd) |
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.
This change ignores the error here. is that intentional?
Since it goes against idioms, maybe it should be commented?
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.
Hi @mogsie
IHMO: We need to have like
_, err = utils.Run(cmd)
Expect(err).NotTo(HaveOccurred(), "Failed to label namespace with restricted policy")
Instead of Expect(utils.Run(cmd)),
which does not make the result/output clear, we risk having an error in the string format outputted when needed.
But if you see any other halls for improvements, can you please raise an issue for each case scenario so that it makes it easier for us to follow up wdyt?
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.
Reported it as #4450
Description
Closes #4423
Main changes:
pod-security.kubernetes.io/enforce=restricted
.securityContext
Pod spec fieldsLabelNamespacesToWarnAboutRestricted()
,RemoveNamespaceLabelToWarnAboutRestricted()
toLabelNamespacesToEnforceRestricted()
,RemoveNamespaceLabelToEnforceRestricted()
.curlimages/curl:latest
instead of pinning a version.