I am trying to get a keepalived running in an unprivileged lxc container, but I get the following error in the syslog.
May 8 10:56:01 dnsmasq Keepalived_vrrp[11025]: Initializing ipvs 2.6
May 8 10:56:01 dnsmasq modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-22-generic/modules.dep.bin'
May 8 10:56:01 dnsmasq Keepalived_vrrp[11025]: IPVS: Can't initialize ipvs: No space left on device
What am I missing. I tried loading ip_vs kernel module on the host but with no success.
Containers aren't allowed to load modules as they share kernel with the host machine. Once you load module on your hardware node, it will become available on all the containers. The same rule is for OpenVZ virtualization.
If you are running LXD you need to allow the Linux Kernel modules to be loaded by the LXC container.
Inside the container you need to set the
-P
option to keepalived in order to use keepalived correctly.To do this on Ubuntu 16.04 you can edit
/etc/defaults/keepalived
and set the following line:DAEMON_ARGS="-P"
If you use liblxc if you load the kernel module on the host container you should be able to load it inside of the LXC container.
I had a similar issue on lxc 4.0.9 on Centos 8 containers with keepalived 1.1.19 sharing this solution to perhaps save you a few hours of your life.
NOTE: all commands run from root acc
package: wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz
By default keepalived in this version is expecting it's config to live in /etc/keepalived/keepalived.conf
config:
If you try to load the config via '/etc/init.d/keepalived start' or use 'systemctl start keepalived' it will throw an error 'keepalived.service: Failed to reset devices.list: Operation not permitted'
instead register your own service.
then reload the systemd deamon systemctl daemon-reload
and do the usual
Enjoy!