简体   繁体   English

使用 OpenShift 进行卷挂载的写入权限

[英]Write permissions on volume mount with OpenShift

Using OpenShift 3.11, I've mounted an nfs persistent volume, but the application cannot copy into the new volume, saying:使用 OpenShift 3.11,我安装了一个 nfs 持久卷,但应用程序无法复制到新卷中,说:

oc logs my-project-77858bc694-6kbm6 
cp: cannot create regular file '/config/dbdata/resdb.lock.db': Permission denied
...

I've tried to change the ownership of the folder by doing a chown in an InitContainers, but it tells me the operation not permitted.我试图通过在 InitContainers 中执行 chown 来更改文件夹的所有权,但它告诉我该操作不允许。

      initContainers:
        - name: chowner
          image:  alpine:latest
          command: ["/bin/sh", "-c"]
          args:
            - ls -alt /config/dbdata; chown 1001:1001 /config/dbdata;
          volumeMounts:
          - name: my-volume
            mountPath: /config/dbdata/ 
oc logs my-project-77858bc694-6kbm6 -c chowner
total 12
drwxr-xr-x    3 root     root          4096 Nov  7 03:06 ..
drwxr-xr-x    2 99       99            4096 Nov  7 02:26 .
chown: /config/dbdata: Operation not permitted

I expect to be able to write to the mounted volume.我希望能够写入已安装的卷。

You can give your Pods permission to write into a volume by using fsGroup: GROUP_ID in a Security Context.您可以通过在安全上下文中使用fsGroup: GROUP_ID来授予 Pod 写入卷的权限。 fsGroup makes your volumes writable by GROUP_ID and makes all processes inside your container part of that group. fsGroup使您的卷可按 GROUP_ID 写入,并使容器内的所有进程成为该组的一部分。

For example:例如:

apiVersion: v1
kind: Pod
metadata:
  name: POD_NAME
spec:
  securityContext:
    fsGroup: GROUP_ID
...

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

相关问题 使用安全上下文 fsgroup 选项对卷装载的写入权限 - Write permissions on volume mount with security context fsgroup option 卷写入权限 - Volume Write Permissions Minikube 卷写入权限? - Minikube volume write permissions? Kubernetes 卷挂载权限不正确 - Kubernetes Volume Mount Permissions Incorrect For Secret Azure kube.netes - 将 Azure blob 安装为一个卷并使用 python 写入? - Azure kubernetes - mount Azure blob as a volume and write using python? 读/写模式下configmap中的大三角帆安装卷(0666) - spinnaker mount volume from configmap in read/write mode (0666) 通过 OpenShift 3.11 PersistentVolume 挂载 NFS 卷:mount.nfs:挂载失败,服务器给出的原因:没有这样的文件或目录 - Mounting a NFS volume by a OpenShift 3.11 PersistentVolume: mount.nfs: mounting failed, reason given by server: No such file or directory 我有一个卷挂载到 Kubernetes pod 中,卷有 644 权限,但容器用户是非 root,我可以强制挂载为 777 吗? - I have a volume mounted into a Kubernetes pod, the volume has 644 permissions, but the container user is non-root, can I force mount as 777? 使用 minikube 作为 docker 桌面替代品的共享卷写入权限问题 - Problem with shared volume write permissions using minikube as a docker desktop replacement CephFS 卷挂载失败 - CephFS Volume Mount Fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM