Closed realSConway closed 1 year ago
SELinux is blocking the access.
I have read about rootless and SELinux, specifically: https://www.redhat.com/sysadmin/user-namespaces-selinux-rootless-containers
Shouldn't pods be sharing same namespace?
Containers within a Pod share the same namespaces and SELinux labels. If you are sharing a volume between two different pods, then I usually advise to label the volumes with s0
level, so that all of the containers within the pod, and all containers in general, can read/write the content in the volume. From an SELinux point of view.
Ok, then that isn't my issue, volumes are not shared between containers.
It seems I can only mount one volume which is defined in annotations > bind-mount-options
?
...etc
annotations:
#bind-mount-options: /home/support/podman/documents/webtest/hidden_service:Z
bind-mount-options: /data/monero:Z
...etc
A friendly reminder that this issue had no activity for 30 days.
:z versus :Z would relabel with a shared label. I don't think this is a podman issue, so closing.
I think this is still an issue. The problem is that with the bind-mount-options
entry, it's only possible to specify a single mount. A trivial pod with two volumes (not shared) that depend on the :Z flag won't work because the generated yaml file will only select one of the volumes to write into bind-mount-options
.
I ran into this today trying to use the generate kube
command for the first time. My pod fails because one of the two volumes doesn't get relabeled automatically.
It seems the only workaround currently is to fix SELinux issues manually, and not expect podman generate
/podman play
to do it for you.
For extra clarity, here's an error from podman 4.6.2 if I try to edit the generated YAML file to use a list in order to support two mounts:
# Created with podman-4.6.2
apiVersion: v1
kind: Pod
metadata:
annotations:
bind-mount-options:
- /var/data/myservice/app:Z
- /var/data/myservice/db:Z
#...
podman play kube ...
produces this error:
Error: unable to read YAML as Kube Pod: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field ObjectMeta.metadata.annotations of type string
I assume the solution would involve some refactoring in that general direction, but I'm not familiar enough with this project to work on it myself.
Issue Description
When using podman generate kube command to create Kubernetes YAML files for a pod containing two containers, I encountered an issue with bind-mounting directories. Specifically, when I set the annotations: bind-mount-options for the database directory, the configuration file becomes unreadable, leading to the following error message:
Could not open "/etc/tor/torrc": Permission denied
Setting annotations: bind-mount-options for the conf file results in another error related to the database directory:Exception in main! boost::filesystem::status: Permission denied [system:13]: "/home/database/lmdb
I have moved both item (hidden_service and torrc) to /data/monero but error still occurs.
Steps to reproduce the issue
podman generate kube monero
output:
podman kube play ./pod-monero.yaml
bind-mount-options
Describe the results you received
Permission denied
Describe the results you expected
The pod should be successfully created with both containers, and the specified directories should be properly mounted. The configuration file should be readable, and no permission denied errors should occur.
podman info output