Bug 1317023 - SELinux prevents mounted ca.crt and token from being read in a Kubernetes pod
Summary: SELinux prevents mounted ca.crt and token from being read in a Kubernetes pod
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 23
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-11 17:50 UTC by Stef Walter
Modified: 2018-06-01 10:35 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
: 1361372 (view as bug list)
Environment:
Last Closed: 2016-12-20 19:23:43 UTC
Type: Bug
Embargoed:
stefw: needinfo-


Attachments (Terms of Use)
Script to setup kubernetes (1.54 KB, application/x-shellscript)
2016-03-11 17:52 UTC, Stef Walter
no flags Details
A simple pod to reproduce the issue (544 bytes, text/plain)
2016-03-11 17:53 UTC, Stef Walter
no flags Details

Description Stef Walter 2016-03-11 17:50:33 UTC
Description of problem:

A correctly configured kubernetes will mount a ca.crt and token data into pods at their path:

/var/run/secrets/kubernetes.io/serviceaccount/

However SELinux on the node prevents access to the ca.crt and token files. Turning off SELinux (setenforce 0) allows access again.

Version-Release number of selected component (if applicable):

kubernetes-1.1.0-0.17.git388061f.fc23.x86_64

How reproducible:

Every time.

Comment 1 Stef Walter 2016-03-11 17:52:44 UTC
Created attachment 1135317 [details]
Script to setup kubernetes

Kubernetes as packaged in Fedora requires a scripted  setup before it is able to start pods appropriately. This file is part of reproducing this issue, it should be run before kubernetes services are started.

Comment 2 Stef Walter 2016-03-11 17:53:11 UTC
Created attachment 1135318 [details]
A simple pod to reproduce the issue

Comment 3 Stef Walter 2016-03-11 17:57:05 UTC
Make sure SELinux is enforcing:

# setenforce 1

First setup and start kubernetes:

# wget -o kubernetes.setup https://bugzilla.redhat.com/attachment.cgi?id=1135317
# sh kubernetes.setup
# systemctl start docker etcd kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy

Now deploy a pod to the new kubernetes cluster:

# wget -o pod.json https://bugzilla.redhat.com/attachment.cgi?id=1135318
# kubectl create -f pod.json

Wait for the pod to start:

# kubectl get pods

Now log into the pod and try to access the mounted secrets:

# kubectl exec -ti tiny /bin/cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

Actual results:

# kubectl exec -ti tiny /bin/cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
cat: can't open '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt': Permission denied
error: Error executing remote command: Error executing command in container: Error executing in Docker Container: 1

Expected results (which you can see if you setenforce 0):

# kubectl exec -ti tiny /bin/cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
-----BEGIN CERTIFICATE-----
MIIC/TCCAeWgAwIBAgIJAJBPiGTbKtEeMA0GCSqGSIb3DQEBCwUAMBUxEzARBgNV
BAMMCmt1YmVybmV0ZXMwHhcNMTYwMzExMTc0MDQ0WhcNMjQwODA4MTc0MDQ0WjAV
MRMwEQYDVQQDDAprdWJlcm5ldGVzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEA20PGPb5EPdf76bFO5/jdbIER6wlQsuERqCi7B50KtoxM41JF1RcmRX1W
...

Comment 4 Eric Paris 2016-03-11 18:01:05 UTC
Paul, haven't we talked about this like 1bazillion times? We need to label /var/lib/kubelet/something differently?

Comment 5 Daniel Walsh 2016-03-11 20:51:46 UTC
Are these specific to each pod, or do they need to be shared between all pods?

Comment 6 Stef Walter 2016-03-17 07:43:58 UTC
> Are these specific to each pod, or do they need to be shared between all pods?

The CA is shared between all pods. I believe the token file is specific to the pods serviceaccount configuration.

Comment 7 Daniel Walsh 2016-03-17 20:11:19 UTC
Then they should be mounted shared.

Comment 8 Paul Morie 2016-08-22 16:57:06 UTC
/var/lib/kubelet needs to be labeled with svirt_sandbox_file_t for mounts like this to work correctly.

I notice this issue is still open from March -- is this still an issue?

Comment 9 Fedora End Of Life 2016-11-24 16:02:03 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 10 Fedora End Of Life 2016-12-20 19:23:43 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.