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

permissions – 允许对非root用户访问PersistentVolumeClaim,第1张

概述在kubernetes中,我可以使用 PersistentVolumeClaim来创建一些存储空间,稍后我可以将其存储在某个容器中. 但是,如果容器中的用户不是root用户,则该用户将无法访问该目录,因为它由root拥有. 访问这样一个卷的正确方法是什么? (在创建和安装该卷时,我没有找到任何用户/权限选项.) 首先,找出您的进程正在运行的UID号. 然后你可以通过添加.spec.security 在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全部内容,希望文章能够帮你解决permissions – 允许对非root用户访问PersistentVolumeClaim所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1047569.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存