Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman no-priv in K8s (on Talos on Hardware) #26

Open
hh opened this issue May 7, 2024 · 1 comment
Open

Podman no-priv in K8s (on Talos on Hardware) #26

hh opened this issue May 7, 2024 · 1 comment

Comments

@hh
Copy link
Member

hh commented May 7, 2024

Exploring Rootless Podman w/o the privileged flag: https://www.redhat.com/sysadmin/podman-inside-kubernetes

Which will require we use a fuse-device-plugin similar to this one:

https://github.com/kuberenetes-learning-group/fuse-device-plugin/tree/master (is two years old...)

The fus-device-plugin deployed, and then I tried running it without a shared volume mount, but seems to need host path, which needs to be limited via some type of policy.

podman run ubi8 echo hello
WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers 
cannot clone: Operation not permitted
Error: cannot re-exec process

This is basically the following:

rootless-no-priv.yaml

apiVersion: v1
kind: Pod
metadata:
 name: no-priv
spec:
 containers:
   - name: no-priv
     image: quay.io/podman/stable
     args:
       - sleep
       - "1000000"
     securityContext:
       runAsUser: 1000
     resources:
       limits:
         github.com/fuse: 1
##### above here only, Podman complains about missing mount with rootless containers
##### Adding below here is going to require some changes to the security policy
     volumeMounts:
       - mountPath: /home/podman/.local/share/containers
         name: podman-local
 volumes:
   - name: podman-local
     hostPath:
       path: /home/umohnani/.local/share/containers

Here is an old way with PodSecurityPolicy: https://dev.to/mxglt/kubernetes-give-rights-for-hostpath-volumes-to-services-121f
However PSP seems to have been deprecated / removed by 1.25: https://kubernetes.io/docs/concepts/security/pod-security-policy/

There is a migration path: https://kubernetes.io/docs/tasks/configure-pod-container/migrate-from-psp/
And it seems allowedHostPaths will need to be covered by an admission web hook: https://kubernetes.io/docs/tasks/configure-pod-container/migrate-from-psp/#eliminate-non-standard-options

May need to loop back around.

@hh
Copy link
Member Author

hh commented May 7, 2024

Getting a bit further, now it's permissions... but still not a clear path.
Was hoping fsGroup and fsGroupChangePolicy would help:

https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods

apiVersion: v1
kind: Pod
metadata:
 name: d
spec:
 securityContext:
   runAsUser: 1000
   runAsGroup: 1000
   fsGroup: 1000
   # fsGroupChangePolicy: "OnRootMismatch"
   fsGroupChangePolicy: "Always"
 containers:
   - name: no-priv
     image: quay.io/podman/stable
     args:
       - sleep
       - "1000000"
     securityContext:
       runAsUser: 1000
       runAsGroup: 1000
     resources:
       limits:
         github.com/fuse: 1
     volumeMounts:
       - mountPath: /home/podman/.local/share/containers
         name: podman-local
 volumes:
   - name: podman-local
     hostPath:
       path: /var/local/podman
podman run ubi8 echo hello
Error: creating runtime static files directory "/home/podman/.local/share/containers/storage/libpod": mkdir /home/podman/.local/share/containers/storage: permission denied

@hh hh changed the title Podman no-priv in K8s Podman no-priv in K8s (on Talos on Hardware) May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant