Skip to content

Running Microk8s in an unprivileged LXD container #2755

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

Open
matjazp opened this issue Nov 25, 2021 · 12 comments
Open

Running Microk8s in an unprivileged LXD container #2755

matjazp opened this issue Nov 25, 2021 · 12 comments

Comments

@matjazp
Copy link

matjazp commented Nov 25, 2021

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?

@ktsakalozos
Copy link
Member

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.

@sashati
Copy link

sashati commented Feb 1, 2022

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?

@stale
Copy link

stale bot commented Dec 28, 2022

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 stale bot added the inactive label Dec 28, 2022
@stale stale bot closed this as completed Jan 27, 2023
@neoaggelos
Copy link
Contributor

neoaggelos commented Jan 27, 2023

not stale, not completed

@neoaggelos neoaggelos reopened this Jan 27, 2023
@stale stale bot removed the inactive label Jan 27, 2023
@dalbani
Copy link
Contributor

dalbani commented Apr 20, 2023

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
Copy link
Contributor

dalbani commented May 10, 2023

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: k3s-io/k3s#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?

@ktsakalozos
Copy link
Member

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

@dalbani
Copy link
Contributor

dalbani commented May 16, 2023

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

@matjazp
Copy link
Author

matjazp commented May 16, 2023

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

Copy link

stale bot commented Apr 10, 2024

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 stale bot added the inactive label Apr 10, 2024
@dalbani
Copy link
Contributor

dalbani commented Apr 10, 2024

/unstale

@stale stale bot removed the inactive label Apr 10, 2024
@Pictor13
Copy link

Pictor13 commented Sep 5, 2024

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.

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

6 participants