Running Kubernetes in container on Fedora/CentOS

Running Kubernetes cluster on docker container on fedora or CentOS can be problematic specially with SELinux. So you need to do small settings before you follow setup mentioned on Kubernetes docs.

m7S2-kubernetes

This is because the Kubernetes container you will run will be running in privileged mode. And when doing that this container will be doing reads and writes on host machine. And SELinux by default won’t allow that, to enable that you have to change SELinux Security context.

infinity-logo_400x400

And this is to be done specifically on folders that will be mounted as volume in Kubernetes container. So if you follow the instructions on Kubernetes docs, it mounts /var/lib/kubelet/ and /var/lib/docker/ from host system into Kubernetes container. Also the folder /var/lib/kubelet/ won’t be there by already so create it and change its context.

selinux-penguin-new_sized

So run below commands and then follow docs.

sudo mkdir -p /var/lib/kubelet/
sudo chcon -R -t svirt_sandbox_file_t /var/lib/kubelet/
sudo chcon -R -t svirt_sandbox_file_t /var/lib/docker/

Here is small script that you may follow, just for reference.

One thought on “Running Kubernetes in container on Fedora/CentOS

Leave a comment