microk8s icon indicating copy to clipboard operation
microk8s copied to clipboard

Running Microk8s in an unprivileged LXD container

Open matjazp opened this issue 3 years ago • 12 comments

Official docs for running Microk8s inside LXD containers still define microk8s LXD profile that runs it in as a privileged container and also disables a bunch of other security related features.

What is missing to run Microk8s in a regular, unprivileged container? I'm running Microk8s in a VM, but would love to have an option for running it in (unprivileged) containers. You can already run Docker like that, so nested container runtimes are probably not the main issue?

matjazp avatar Nov 25 '21 20:11 matjazp

The profile we have for LXD is very permissive so as to not block any workloads users may want to run in Kubernetes. Users with well defined workloads can start with the wide open LXD profile and try to make it less permissive allowing only the capabilities their workload requires.

ktsakalozos avatar Dec 02 '21 21:12 ktsakalozos

I face with the same issue. As you know the nvidia.runtime just works in unprivileged mode. Then if we want to utilize GPU on MicroK8s, there is indeed no way. Does anyone find a solution for MicroK8s on unprivileged LXC?

sashati avatar Feb 01 '22 14:02 sashati

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 28 '22 14:12 stale[bot]

not stale, not completed

neoaggelos avatar Jan 27 '23 15:01 neoaggelos

Coming here from https://github.com/lxc/lxd/issues/4184, my understanding is that having the ability to run MicroK8s in an unprivileged container would open up possibilities with ZFS zones.

@stgraber wrote in particular:

Because the zfs zone stuff is based on the user namespace, I don't expect it to ever work with security.privileged=true as that turns off the user namespace. You'd need to get microk8s working properly without security.privileged=true for any of this to work there.

I'm not sure I fully understood your comment, @ktsakalozos. You talked about (specific) workloads, but what about MicroK8s itself first. Can it (be made to) work in an unprivileged container?

dalbani avatar Apr 20 '23 20:04 dalbani

I'm not sure if it's relevant to this discussion, but I stumbled upon this concept of "rootless mode" in Kubernetes: https://kubernetes.io/docs/tasks/administer-cluster/kubelet-in-userns/

This document describes how to run Kubernetes Node components such as kubelet, CRI, OCI, and CNI without root privileges, by using a user namespace.

Which relies on the KubeletInUserNamespace feature gate from what I can read.

And while we're talking about MicroK8s here, I found some similar discussion regarding K3s: https://github.com/k3s-io/k3s/issues/4249.

KubeletInUserNamespace is not set in unprivileged LXD containers when k3s is run as root

And, from the discussion on this page, it looks like K3s does work in an unprivileged LXD container thanks to this mode. Or am I understanding it incorrectly?

If my interpretation is correct, could the same capability be built in MicroK8s?

dalbani avatar May 10 '23 20:05 dalbani

@dalbani this is an interesting feature/setup configuration that up to this point we have not looked into it.

ktsakalozos avatar May 15 '23 06:05 ktsakalozos

Thanks @ktsakalozos for the feedback 👍 For the record, a competitor product like K3s offers an (experimental) rootless mode: https://docs.k3s.io/advanced#running-rootless-servers-experimental

dalbani avatar May 16 '23 07:05 dalbani

Rootless mode can be a welcomed addition, but it (currently) has many limitations (see docs). I would still prefer a regular K8s.

matjazp avatar May 16 '23 08:05 matjazp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 10 '24 21:04 stale[bot]

/unstale

dalbani avatar Apr 10 '24 21:04 dalbani

What's the status?
Is it mandatory to use a privileged Docker context, for now, in order to run MicroK8s?
Is it a requirement?

~Installing recent Docker on Linux releases seems to use rootless context by default.~

Pictor13 avatar Sep 05 '24 10:09 Pictor13