-
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
proposal for file permission handling in projected service account volume #1598
Conversation
Hi @zshihang. Thanks for your PR. I'm waiting for a kubernetes 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/test-infra repository. |
/cc @mikedanese |
313a588
to
1f17ed9
Compare
/assign @saad-ali |
|
||
UserID can be obtained by the following three ways: | ||
1. `runAsUser` in `SecurityContext` | ||
2. fetch UserID from image status |
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.
are all images pulled and present by the time we need to create the volume for mounting and choose a file mode (including volumes we would need to create for initContainers)?
also, can the preferred uid/gid for an image change over the life of a pod if a container image is changed in the pod spec or is restarted/repulled?
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.
no, all volumes are mounted before SyncPod
is called in kuberuntime manager. this proposal will not work without alternation on the existing abstraction of kuberuntime manager and volume manager.
good point. the uid/gid will not change if a new image with different uid/gid is pulled. this will be an issue for uid but not for gid because the user in the new image will be added to the gid. to work around this changing uid issue, we have to change the ownership each pulling, which requires implementing a SetOwnership method without remounting. talked to @saad-ali about the implications of this method: 1. "the operation is recursive and can take many many minutes to complete for volumes with lots of files and directories." 2. some files might be used by containers while being updated with new permissions.
the complexity of solving both issues is high when introducing the uid in images. ideally in this case we have to push container runtime side to add a functionality to set ownership of volume mounts. see moby/moby#2259. then we can set ownership uid-wise.
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.
I don't think the recursive SetOwnership is a concern for this particularly case. It's only problematic for very large volumes with lots of files. But changing permissions of files while they're in use is a concern.
1. same as the proposal except for creating a different volume for a different | ||
user ID instead of setting GroupID ownership. | ||
+ projected service account token is a pod level resource | ||
+ scalability issue. # of volumes = # of user IDs. |
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.
if we reuse the same token (to avoid a renewal loop per container), is the scale we'd hit at up to one volume per container problematic?
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.
We have the data in cache in the kubelet so this is purely scalability of kubelet volume management. IMO the major downside of this approach is implementation complexity.
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.
yes, besides the implementation complexity of managing volumes for different uids, i'd also like the unix primitive idea of group.
I am fine limiting the scope to projected service account volumes for now, and revisiting other ephemeral volumes as a future enhancement. |
@@ -159,6 +161,55 @@ sources: | |||
audience: ca.istio.io | |||
``` | |||
|
|||
### File Permission |
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.
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.
SELinux labels on files are orthogonal to UID/GIDs and are set by the container runtime when pods start.
#1621 tries to change it, still, it's separate from file owners and permissions.
From sig-auth. /lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikedanese, msau42, zshihang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@zshihang @mikedanese has there been any documentation added to k/website for this behavior? I would be happy to add some if not :) |
feel free to do so. |
this-week: 2024-03-15
Motivation:
currently the mode of projected service account volume is 0600 effectively 0400, which may not work in pods with non-root containers. see kubernetes/kubernetes#74565.
Proposal:
token file to 0600 and let the fsGroup mechanism work as designed. It will
set the permissions to 0640, chown the token file to the fsGroup and start
the containers with a supplemental group that grants them access to the
token file. This works today.
in the pod. We chown the token file to the pod’s runAsUser to grant the
containers access to the token.
behavior of secrets.
Ref: kubernetes/kubernetes#70679
Ref: #542