gpt4 book ai didi

permissions - 允许非 root 用户访问 PersistentVolumeClaim

转载 作者:行者123 更新时间:2023-12-03 16:46:50 24 4
gpt4 key购买 nike

在 kubernetes 中,我可以使用 PersistentVolumeClaim创建一些存储,稍后我可以将其安装在某个容器中。

但是,如果容器中的用户不是 root,则该用户将无法访问该目录,因为它归 root 所有。

访问这样一个卷的正确方法是什么? (在创建和安装该卷时,我没有找到任何用户/权限选项。)

最佳答案

首先,找出您的进程正在运行的 UID 号。

然后,您可以通过添加 .spec.securityContext.fsGroup 来告诉 Kubernetes chown(某种程度)您的 pod 的卷挂载点。 :

spec:
...
securityContext:
fsGroup: 2000

fsGroup: integer: A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- If unset, the Kubelet will not modify the ownership and permissions of any volume.

关于permissions - 允许非 root 用户访问 PersistentVolumeClaim,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46873796/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com