cluster-api
cluster-api copied to clipboard
🌱 Implement privileged namespace security policy update for tilt-prepare
What this PR does / why we need it:
This PR creates a updateNamespacePodSecurityStandard function to ensure that the pod-security.kubernetes.io/enforce label is set to "privileged" for Namespace objects. This change is essential for compatibility with CAPIs tilt-prepare and Tiltfile when using CAPM3 (and other providers?), where accessing securityContext is required. Without this update, the existing pod-security policy restricts the usage of securityContext, hindering necessary operations. This aligns the behavior with CAPD, where the privileged policy is already set for Namespace objects.
/area provider/infrastructure-in-memory
@maxrantil: The label(s) area/ cannot be applied, because the repository doesn't have them.
In response to this:
What this PR does / why we need it: This PR creates a
updateNamespaceSecurityPolicyfunction to ensure that thepod-security.kubernetes.io/enforcelabel is set to"privileged"for Namespace objects. This change is essential for compatibility with CAPIs tilt-prepare and Tiltfile when using CAPM3 (and other providers?), where accessing securityContext is required. Without this update, the existing pod-security policy restricts the usage of securityContext, hindering necessary operations. This aligns the behavior with CAPD, where the privileged policy is already set for Namespace objects./area provider/infrastructure-in-memory
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/test-infra repository.
Hi @maxrantil. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
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/test-infra repository.
/ok-to-test
/remove-area provider/infrastructure-in-memory
/area devtools
This change is essential for compatibility with CAPIs tilt-prepare and Tiltfile when using CAPM3 (and other providers?), where accessing securityContext is required. Without this update, the existing pod-security policy restricts the usage of securityContext, hindering necessary operations. This aligns the behavior with CAPD, where the privileged policy is already set for Namespace objects.
I just wanted to clarify this a bit. Tilt-prepare already removes the security context from the deployments, but this is not enough if the namespace has enforced pod security standards. The issue is not visible for CAPI/CAPD since CAPD anyway uses the privileged policy in order to mount the docker socket. Other providers will likely be able to run with a restricted policy for the namespace, except when using Tilt. This is why we want to make tilt-prepare change the label on the namespace.
This change is essential for compatibility with CAPIs tilt-prepare and Tiltfile when using CAPM3 (and other providers?), where accessing securityContext is required. Without this update, the existing pod-security policy restricts the usage of securityContext, hindering necessary operations. This aligns the behavior with CAPD, where the privileged policy is already set for Namespace objects.
I just wanted to clarify this a bit. Tilt-prepare already removes the security context from the deployments, but this is not enough if the namespace has enforced pod security standards. The issue is not visible for CAPI/CAPD since CAPD anyway uses the privileged policy in order to mount the docker socket. Other providers will likely be able to run with a restricted policy for the namespace, except when using Tilt. This is why we want to make tilt-prepare change the label on the namespace.
100% agree, this gets helpful when PSA is enforced in a clusters and we want to run a provider or the core CAPI providers using tilt. Core CAPI controllers should be affected to, only CAPD not because it requires privileged anyway.
Edit: it comes down to that the reason for wanting this in tilt-prepare is this line in tilt-prepare: https://github.com/kubernetes-sigs/cluster-api/blob/09f3520ff8e081485cde7840dff7bf08896a94a9/hack/tools/internal/tilt-prepare/main.go#L800
Good point! So the reason it is currently working for CAPI is that there are no restrictions on the namespace. Probably the same for many other providers.
@chrischdi appreciate it a lot, thank you!
LGTM label has been added.
/cc @killianmuldoon @JoelSpeed
LGTM label has been added.
/lgtm
LGTM label has been added.
/cc @killianmuldoon @JoelSpeed would any of you please be willing to do a review?
LGTM label has been added.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: killianmuldoon
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [killianmuldoon]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment