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.

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s