ubuntu下部署K8s集群的时候报错haproxy.service: Failed with result 'exit-code'
配置k8s的haproxy时报错如下
haproxy.service - HAProxy Load Balancer
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-05-05 20:34:36 CST; 9min ago
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: 3493 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)
May 05 20:34:36 kubemaster systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
May 05 20:34:36 kubemaster systemd[1]: Stopped HAProxy Load Balancer.
May 05 20:34:36 kubemaster systemd[1]: haproxy.service: Start request repeated too quickly.
May 05 20:34:36 kubemaster systemd[1]: haproxy.service: Failed with result 'exit-code'.
May 05 20:34:36 kubemaster systemd[1]: Failed to start HAProxy Load Balancer.
这个很难看出啥,99%概率是配置文件无法加载,需要具体看下加载配置文件到哪一行报错
/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg 返回结果显示配置文件的第36行和第43行有问题
我的配置文件配置的第36行和43行配置如下(格式来源于redhat下的haproxy配置文件,我实际使用环境是Ubuntu的):
根据报错提示让使用bind关键字监听地址,修改配置文件如下:
重启haproxy服务正常
这个原因猜测可能跟版本有关系,未验证:redhat默认安装的是1.5.18-el7.x86_64,ubuntu默认安装的是2.0.13-2ubuntu0.5
界面验证ok: