Bug 1317023 - SELinux prevents mounted ca.crt and token from being read in a Kubernetes pod [NEEDINFO]
SELinux prevents mounted ca.crt and token from being read in a Kubernetes pod
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted (Show other bugs)
23
Unspecified Unspecified
high Severity high
: ---
: ---
Assigned To: Miroslav Grepl
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-11 12:50 EST by Stef Walter
Modified: 2016-12-20 14:23 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1361372 (view as bug list)
Environment:
Last Closed: 2016-12-20 14:23:43 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
pmorie: needinfo? (stefw)


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

  None (edit)
Description Stef Walter 2016-03-11 12:50:33 EST
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 12:52 EST
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 12:53 EST
Created attachment 1135318 [details]
A simple pod to reproduce the issue
Comment 3 Stef Walter 2016-03-11 12:57:05 EST
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 13:01:05 EST
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 15:51:46 EST
Are these specific to each pod, or do they need to be shared between all pods?
Comment 6 Stef Walter 2016-03-17 03:43:58 EDT
> 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 16:11:19 EDT
Then they should be mounted shared.
Comment 8 Paul Morie 2016-08-22 12:57:06 EDT
/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 11:02:03 EST
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 14:23:43 EST
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.