Kubernetes does not start the service once deployed the container

8/30/2018

I am trying to create a Haproxy in a Kubernetes cluster. So far so good, I manage to create the Docker Image and add the haproxy details. I am able to deploy it in kubernetes, but once deployed, all pods have 0/1 available because the haproxy service does not start.

Am I missing something here?

This is the docker image that I use:

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
-- razvanli
docker
haproxy
kubernetes

1 Answer

8/30/2018

I am assuming you are using the haproxy published in dockerhub. You are overriding the CMD defined in the base image. CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]

You dont run "service" inside docker containers.

If you look at the base image all it does is run haproxy command. By default haproxy runs in the background and in order to make it run in foreground make sure you comment out the 'daemon' in your haproxy.cfg file.

-- Bal Chua
Source: StackOverflow