Repository navigation
Conversation
|
Hi @yu2003w. Thanks for your PR. I'm waiting for a knative 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. DetailsInstructions 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. |
| spec: | ||
| allowPrivilegeEscalation: true | ||
| allowedCapabilities: | ||
| - 'NET_ADMIN' |
There was a problem hiding this comment.
We only need this for cases where we install istio with sidecar injection enabled, right?
There was a problem hiding this comment.
Yes, serving activator and autoscaler need "NET_ADMIN" to startup.
There was a problem hiding this comment.
I think I'd rather have this in test/config until we figure out if/what we want to ship.
There was a problem hiding this comment.
@yu2003w I don't think it's the actual activator/autoscaler but rather the istio sidecars (or init containers in this case) that need these permissions.
There was a problem hiding this comment.
@markusthoemmes Sorry, I misunderstood that. It's Istio sidecar needs the permission.
There was a problem hiding this comment.
@mattmoor Moved psp.yaml to test/config.
When both psp and Istio sidecar automatically injection are enabled, deployments in namespace serving-tests also need 'NET_ADMIN'. So I also defined role and rolebinding within namespace serving-tests.
| seLinux: | ||
| rule: RunAsAny | ||
| supplementalGroups: | ||
| rule: RunAsAny |
There was a problem hiding this comment.
Do these things need to be as permissive as they are given that we've stopped running as root?
There was a problem hiding this comment.
Because these fields are mandatory, without them, PSP couldn't created.
Without them following errors will be reported
error: error validating "psp.yaml": error validating data: [ValidationError(PodSecurityPolicy.spec): missing required field "seLinux" in io.k8s.api.extensions.v1beta1.PodSecurityPolicySpec, ValidationError(PodSecurityPolicy.spec): missing required field "runAsUser" in io.k8s.api.extensions.v1beta1.PodSecurityPolicySpec, ValidationError(PodSecurityPolicy.spec): missing required field "supplementalGroups" in io.k8s.api.extensions.v1beta1.PodSecurityPolicySpec, ValidationError(PodSecurityPolicy.spec): missing required field "fsGroup" in io.k8s.api.extensions.v1beta1.PodSecurityPolicySpec]; if you choose to ignore these errors, turn validation off with --validate=false
There was a problem hiding this comment.
I'm pretty new to PSP, but this looks like it allows us to do anything, so I'm curious how this is an improvement over where we were prior to :nonroot?
There was a problem hiding this comment.
Actually, if PSP is used, :nonroot images is not necessary any more.
Another choice is hand over PSP related stuff to cluster administrator to handle.
There was a problem hiding this comment.
Now I am more confused :)
If PSP validates the USER then shouldn't it block our controllers, which run as root (without :nonroot)?
Maybe the answer is that I need to read what this does...
There was a problem hiding this comment.
If PSP validates user and container needs to be run as root, it will be blocked.
For example, I created psp for Knative serving as below,
root@filmy1:/mnt/data/gowork/src/github.com/knative/serving# knative get psp knative-serving-psp
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP READONLYROOTFS VOLUMES
knative-serving-psp true NET_ADMIN RunAsAny MustRunAsNonRoot RunAsAny RunAsAny false *
Then I build knative serving with base images ubuntu which need to run as root.
Pod failed to start as below,
Normal Pulling 3m34s kubelet, 172.16.17.35 pulling image "icpdev.icp:8500/imgrepo/controller-43f0364ab2f6dab17267e80a1f6a4adc@sha256:4806fc2cc89330d8731385033012f4f04ebc43d5f4918af999b7528162e9dd2b"
Normal Pulled 3m30s kubelet, 172.16.17.35 Successfully pulled image "icpdev.icp:8500/imgrepo/controller-43f0364ab2f6dab17267e80a1f6a4adc@sha256:4806fc2cc89330d8731385033012f4f04ebc43d5f4918af999b7528162e9dd2b"
Warning Failed 76s (x12 over 3m30s) kubelet, 172.16.17.35 Error: container has runAsNonRoot and image will run as root
Normal Pulled 76s (x11 over 3m29s) kubelet, 172.16.17.35 Container image "icpdev.icp:8500/imgrepo/controller-43f0364ab2f6dab17267e80a1f6a4adc@sha256:4806fc2cc89330d8731385033012f4f04ebc43d5f4918af999b7528162e9dd2b" already present on machine
There was a problem hiding this comment.
If Istio auto injection is enabled, it needs capability of 'NET_ADMIN' and needs to be run as root. And RunAsUser in psp should be set to RunAsAny.
There was a problem hiding this comment.
Ok, so tl;dr this is the PSP one needs with Istio Mesh, which is scary.
What I'm wondering is what knative/serving needs when run without sidecars, e.g. istio-lean.yaml?
My hope was for us to be less scary (and use PSP to verify that), but I see little value in testing it in scenarios where the mesh potentially masks all of our work. If we end up needing two PSPs (mesh and no-mesh) that's fine, and we can tweak scripts to install the right ones.
thanks for your patience while I wrap my head around this.
markusthoemmes
left a comment
There was a problem hiding this comment.
/ok-to-test
We should indeed be a lot less scary in plain Knative. As this is only needed if we install via Istio, I'd be quite hesitant to require such privileges unconditionally.
|
Currently no api could be used for determine which admission controller are enabled. |
|
@yu2003w right, so should we hide this behind a label so users only install this if they really need it? On another note: This is kinda only related to istio and the way its configured. It's not really about Knative itself. Should this move into third_party and be documented accordingly? /assign @mattmoor |
|
I have mixed feelings about this. This is it's effectively testing Istio, not Knative, as it is oriented into such a permissive mode almost entirely driven by the injected sidecar. I'm skeptical that it provides any meaningful coverage of Knative itself. I actually like @markusthoemmes |
|
Not sure why this was moved to test/config @yu2003w. I think this can be useful in mesh-cases and if the user wants to install istio. As such, I think it can live under third-party/istio* |
Sorry, I just read the comments. |
e703dee to
271675d
Compare
|
@markusthoemmes I move the PSP related stuff to thirdparty/istio-psp.yaml. |
|
Moving to Can we add:
|
… is enabled in k8s cluster, user should also run 'kubectl apply -f ./thirdparty/istio-psp.yaml' before installing knative serving. Signed-off-by: Wei Yu(Jared) <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yu2003w The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@mattmoor I added back psp related files to test/config/psp. To run tests with PodSecurityPolicy enabled, user could run 'ko apply -f test/config -f test/config/psp' to generate necessary stuff. I think that PSP is not needed if mesh is not enabled.(label of Istio-injection is not enabled for namespace) After testing, I found that only volume types of 'configMap', 'emptyDir' and 'secret' are needed for istio sidecar. So istio-psp.yaml is updated. Currently, maybe it's impossible to add logic to install appropriate psp along side with istio because it's difficult to determine which admission plugin are enabled when k8s api-server is started. kubernetes#79735 It's possibly psp couldn't be installed alongside with istio automatically until kubernetes#79735 is resolved. If I misunderstood something or any other comments, please let me know. Thanks. |
I understand that in general, however, we know which Istio each of our test setups install. My hope was that we could configure the appropriate PSP with each of them vs. having a "lowest common demoninator" PSP that leaves a hole so big (due to the sidecar requirements) that you could drive a truck through it :( Like I said, the most interesting PSP to me isn't Perhaps we could try to schedule a call to discuss this further because going back and forth here seems to be going in circles, and I'd like to make the best use of everyone's time. Want to follow up in #networking or a group chat? |
|
Any updates? Been hanging for a good 3 months now with no activity. |
|
It hung another month. Closing for now, feel free to reopen if still valid. /close |
|
@markusthoemmes: Closed this PR. DetailsIn response to this:
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. |
Signed-off-by: Wei Yu(Jared) [email protected]
Fixes #4480
Proposed Changes
This PR partially fix Enable PodSecurityPolicy in our test environment #4480.
Release Note