简体   繁体   English

如何为kubernetes中的共享卷授予完全权限

[英]How to give full permissions to a shared volume in kubernetes

I have a container which is using shared volume with host. 我有一个使用主机共享卷的容器。 I want to give it a full permissions. 我想给它一个完整的权限。 At present, it is: 目前是:

ls -l
drwxr-xr-x 8 user user 4096 Aug  9 04:47 Data

But I want it to be: 但我希望它是:

ls -l
drwxrwxrwx 8 user user 4096 Aug  9 04:47 Data

I have a below deployment file: 我有以下部署文件:

----
----
spec:
  containers:
  - name: logger
    image: logger_image
    volumeMounts:
    - mountPath: /Data
      name: Data-files
    securityContext:  
      privileged: true

 volumes:
  - name: Data-files
    hostPath:
      path: /home/user/Documents/Data

----
----

I have even set it as privileged but still, the volumes do not have full permissions. 我什至已将其设置为privileged但仍然没有卷的完全权限。 What should I add in deployment file to make the volume full permissions? 我应该在部署文件中添加什么以使卷具有完全权限?

Thanks 谢谢

Your permissions on /home/user/ or /home/user/Documents/ folders don't allow the process' owner (of logger_image) to access the folder and write. 您对/home/user//home/user/Documents/文件夹的权限不允许进程的所有者(logger_image的所有者)访问该文件夹并进行写操作。

Try to create /Data (on your root) and set the proper permissions. 尝试在根目录上创建/Data并设置适当的权限。

I resolved this issue by mentioning the appropriate commands to give full permissions to that directory in the Dockerfile itself. 我通过提及适当的命令来解决此问题,以赋予Dockerfile本身对该目录的完全权限。

In the dockerfile: 在dockerfile中:

RUN mkdir -p /Data
RUN chmod 777 -R Data/

and then later used the same kubernetes deployment file and it worked fine with full permissions. 然后使用相同的kubernetes部署文件,并且在具有完全权限的情况下可以正常工作。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM