部署容器后,Kubernetes 不会启动服务
Kubernetes does not start the service once deployed the container
我正在尝试在 Kubernetes 集群中创建 Haproxy。到目前为止一切顺利,我设法创建了 Docker 图像并添加了 haproxy 详细信息。
我可以在 kubernetes 中部署它,但是一旦部署,所有 pods 都有 0/1 可用,因为 haproxy 服务没有启动。
我是不是遗漏了什么?
这是我使用的 docker 图片:
FROM haproxy:1.7
RUN groupadd haproxy && useradd -g haproxy haproxy
COPY haproxy.cfg /etc/haproxy/haproxy.cfg
CMD touch /var/log/haproxy.log && chmod 777 /var/log/haproxy.log
CMD service rsyslog start && service haproxy start && aproxy -f /etc/haproxy/haproxy.cfg
我假设您使用的是 dockerhub 中发布的 haproxy。
您正在覆盖基本映像中定义的 CMD。
CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
您不 运行 "service" 在 docker 个容器内。
如果您查看基本映像,它所做的只是 运行 haproxy 命令。默认情况下,haproxy 运行s 在后台,为了使其在前台 运行,请确保在 haproxy.cfg 文件中注释掉 'daemon'。
我正在尝试在 Kubernetes 集群中创建 Haproxy。到目前为止一切顺利,我设法创建了 Docker 图像并添加了 haproxy 详细信息。 我可以在 kubernetes 中部署它,但是一旦部署,所有 pods 都有 0/1 可用,因为 haproxy 服务没有启动。
我是不是遗漏了什么?
这是我使用的 docker 图片:
FROM haproxy:1.7
RUN groupadd haproxy && useradd -g haproxy haproxy
COPY haproxy.cfg /etc/haproxy/haproxy.cfg
CMD touch /var/log/haproxy.log && chmod 777 /var/log/haproxy.log
CMD service rsyslog start && service haproxy start && aproxy -f /etc/haproxy/haproxy.cfg
我假设您使用的是 dockerhub 中发布的 haproxy。 您正在覆盖基本映像中定义的 CMD。 CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
您不 运行 "service" 在 docker 个容器内。
如果您查看基本映像,它所做的只是 运行 haproxy 命令。默认情况下,haproxy 运行s 在后台,为了使其在前台 运行,请确保在 haproxy.cfg 文件中注释掉 'daemon'。