加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

permissions – 允许对非root用户访问PersistentVolumeClaim

发布时间:2020-12-13 19:17:44 所属栏目:Linux 来源:网络整理
导读:在kubernetes中,我可以使用 PersistentVolumeClaim来创建一些存储空间,稍后我可以将其存储在某个容器中. 但是,如果容器中的用户不是root用户,则该用户将无法访问该目录,因为它由root拥有. 访问这样一个卷的正确方法是什么? (在创建和安装该卷时,我没有找到
在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读