-
Notifications
You must be signed in to change notification settings - Fork 715
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
Document kubeadm usage with SELinux #279
Comments
@pipejakob I added the |
I don't work with kubadmin but would be very willing to help whoever takes this on. |
@rhatdan Great! What I'm looking for is persons that are familiar with SELinux and willing to help. A rough todo list would look like:
@rhatdan Let's first try and get it working in v1.7, can be done in #215 |
I will take for now, since I raised it. I'll have some updates soon, @rhatdan, please advise me ;) |
@luxas , @jasonbrooks - does this still exist in fedora? I think folks have patched policies on other channels. /cc @eparis |
@timothysc I haven't tried w/ 1.7 yet, but w/ 1.6, CentOS worked w/ selinux but Fedora 25 didn't. I'll test w/ 1.7 |
for reference, I just ran kubeadm 1.7 on f26 in permissive mode, and these are the denials I got:
On CentOS 7, same thing, no denials. |
You are volume mounting in content from the host into a container. If you want an SELinux confined process inside the container to be able to read the content, it has to have an SELinux label that the container is allowed to read. Mounting the object with :Z or :z would fix the issue. Note either of these would allow the container to write these objects. If you want to allow the container to read without writing then you could change the content on the host to something like container_share_t. |
kubernetes/kubernetes#48607 will also help here as it starts making mounting everything but etcd read-only... |
@luxas @jasonbrooks - someone want to tinker with adjusting the manifests ( https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ ) ? |
To me it's unclear which policies kubeadm should add to:
- read only mounts
- read write mounts
that is working on CentOS, Fedora _and_ CoreOS
… On 12 Jul 2017, at 16:57, Timothy St. Clair ***@***.***> wrote:
@luxas @jasonbrooks - someone want to tinker with adjusting the manifests ( https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ ) ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@rhatdan It looks like :Z is only used if the pod provides an selinux label. In my initial tests, |
Yes it will be ignored by non SELinux systems. RUnning an app as container_runtime_t, basically provides no SELinux confinement, since it is supposed to be the label of container runtimes like docker and CRI-O. If you are running the kublet as this, that is probably fairly accurate. |
Right now, we're running the etcd container as spc_t -- would it be better to run that one as container_runtime_t too? |
It looks like this does it:
Would this be something to submit as PRs to the 1.7 branch and to master, or just to master? The source moved around a bit in master, the patch above is to the 1.7 branch. |
I would actually prefer that it run as spc_t, or as a confined domain(container_t). etcd should be easily be able to be confined by SELinux. |
I think spc_t should work. I tried w/ container_t and that didn't work. audit2allow says it needs:
|
Could we relabel the certs directory with container_file_t or container_share_t. then it would work. |
kubeadm creates an |
For etcd, the container would need |
I'm trying to figure out if it's legitimate to chcon directories in the rpm spec file -- I see many instances of it in github (https://github.com/search?l=&p=1&q=chcon+extension%3Aspec) but I can't tell whether that's considered good packaging practice or not. We could either change kubeam to run the components as spc_t, unconfined, or we could leave kubeadm alone and chcon the pki dir. |
100% agreed. I'm tempted to say we hold off until CentOS 8 goes GA so we have a consistent baseline wrt to the kernel version across distros. |
if selinux is something that strictly requires e2e tests, we cannot support it today. problem is that the ecosystem has some many distros and flavors that we cannot test them all. |
If we sort out #1379, this would take us a long way towards enabling users who want to have a stricter SELinux setup. I will gather instructions on how you can do SELinux in an unsupported fashion today - either as a blogpost or a doc that can go on docs.k8s.io. Additionally, @TheFoxAtWork did raise SELinux at CNCF SIG Security this week, so wondering if there's broader interest in getting this working. |
One thing that helps here is that the container-selinux package is shared across all of the distros, so maybe ok to add only one. Suggestion is to add CentOS 8 because it'll be on Linux 4.18, which is slightly ahead of Ubuntu 18.04 but not massive enough to start exhibiting other bugs. Amazon Linux 2 is also an option if we're testing on it elsewhere. |
i guess my point was more about the fact that selinux is not something that is really supported on Ubuntu and AppArmor is the alternative for it. https://security.stackexchange.com/a/141716
this is the distro flavor mess that i don't want to get kubeadm into. the kubeadm survey told us that 65% of our users use Ubuntu, so technically we should be prioritizing apparmor. has anyone tried kubeadm with apparmor?
yes, it feels to me we should just document some basic details and punt the rest to #1379. |
AppArmor is much more lightweight than SELinux and has a different security model. It's pretty much on by default these days for Docker on Ubuntu.
Given AppArmor can't be used on CentOS and equivalents (other than AL2 which supports both), we're already there in saying some percentage of users can't make use of a Linux Security Module in a supported fashion. |
I definitely understand the desire to not get into the mess of distros and options -- it's a combinatorial explosion of test configurations. Personally, I believe if kubeadm was at least compatible with selinux it would have a larger share of non-ubuntu users, but I have no proof of that beyond the fact I'm one of those people. However, If the only distro/cri combination that's tested is ubuntu with docker, then that's really the only supported distro/cri. If you don't want to support other configurations that's your choice, but at least be clear about that in the documentation and close this issue now. Telling centos/rhel/fedora users to disable selinux for their entire system because figuring out (and testing) the policy for an application is annoying is the equivalent to telling them to disable their firewall because figuring out (and testing) the rules is annoying. |
actually, i think it's already running in the prow/kubekins image.
currently we are testing containerd and docker on Ubuntu.
we need help with the selinux details. we already tell "CentOS, RHEL or Fedora" users to disable selinux completely: this isn't desired and i still think we should have a document or a paragraph with some guiding steps. |
Filed containerd/cri#1195 to log the fact that there's still work to be done to complete SELinux support in ContainerD. |
Not using system directories or creating custom types for components needing access to these system directories would allow us to further tighten the various components and avoid using spc_t type completely. This is clearly the best solution IMHO. |
I agree. That's why I wanted to test it out and get it working. Based on feedback from @neolit123, I doubt we'll see built-in changes to the code to automatically handle selinux compatibility anytime soon. Instead I'm going to make a doc page that describes how to use kubeadm on systems with selinux. It'll be a few steps longer than the usual kubeadm init process, but it should help anyone who wants to use kubeadm on selinux systems immediately. On that page I'll present three options:
|
Hi, just wanted to comment that we have been running with selinux enabled for almost a year together with kubeadm and kubernetes+docker+calico on Centos7. Most workloads has no issues, had some issues with concourse only that i can recall. However we would like to do better enforcement though at some point, currently we run with /var/lib/etcd (etcd datadir) |
@qpehedm If you could apply a JSONPatch to the static pod manifests, and also make sure kubeadm runs |
@randomvariable Yes to add securitycontext with the spc_t for the k8s static pods as suggested is likely better than our current solution. I suppose the same needs to be done for CNI plugins or other infrastructure containers. Even better would be dedicated labels for this purpose, so that they only get permissions for the specific files needed? |
i'm going to close this ticket and here is my rationale, explained with bullet points:
/close |
@neolit123: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Is this a BUG REPORT or FEATURE REQUEST?
Choose one: BUG REPORT or FEATURE REQUEST
COMMUNITY REQUEST
Versions
All
We need e2e tests that ensure kubeadm works with SELinux on CentOS/Fedora (#215) and CoreOS (#269)
We might be able to add a job for it on kubernetes-anywhere @pipejakob ?
IIUC kubeadm is broken with SELinux enabled right now. The problem is that we don't have one (AFAIK) very experienced with SELinux in the kubeadm team (at least nobody has had time to look into it yet)
AFAIK, the problem is often when mounting
hostPath
volumes...To get closer to production readiness, we should fix this and add a testing suite for it.
We should also work with CNI network providers to make sure they adopt the right SELinux policies as well.
Anyone want to take ownership here? I'm not very experienced with SELinux, so I'm probably gonna focus on other things.
@dgoodwin @aaronlevy @coeki @rhatdan @philips @bboreham @mikedanese @pipejakob
The text was updated successfully, but these errors were encountered: