scholzj / terraform-aws-kubernetes

Terraform module for Kubernetes setup on AWS
Apache License 2.0
200 stars 129 forks source link

etcd down after reboot, selinux issue #24

Closed mvasilenko closed 5 years ago

mvasilenko commented 5 years ago

Hi, thank you for nice terraform k8s setup module, I've faced the issue - after AWS host reboot, etcd was down, etcd container logs:

2019-05-03 17:48:34.873535 C | etcdmain: cannot access data directory: open /var/lib/etcd/.touch: permission denied

Looks like the config file, which is changed during setup

https://github.com/scholzj/terraform-aws-kubernetes/blob/master/scripts/init-aws-kubernetes-master.sh#L60

is actually a symlink

# ls -la /etc/sysconfig/selinux /etc/selinux/config
-rw-r--r--. 1 root root 543 May  3 18:02 /etc/selinux/config
lrwxrwxrwx. 1 root root  17 May  3 18:02 /etc/sysconfig/selinux -> ../selinux/config

but after the setup script, we have two files

# sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
# ls -la /etc/sysconfig/selinux /etc/selinux/config
-rw-r--r--. 1 root root 543 May  3 18:02 /etc/selinux/config
-rw-r--r--. 1 root root 544 May  3 18:02 /etc/sysconfig/selinux

This leads to SELinux being enabled again after reboot/upgrade, and k8s stops functioning because of etcd container is down