[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Building a customized HAProxy Router



Hi Ram,

(and also hi Vaclavm, who wrote me beside the mailing list)

Thank you for your tips and snippets. They pointed me in the right direction. I found it useful to inspect the machine with bash, which I got with this command:

docker run —rm --interactive=true --tty --entrypoint=bash localhost:5000/haproxy-custom

There were some minor issues in the Dockerfile but I got it running. I put this altogether in a blog post: http://www.patrickbreucking.de/wordpress/2016/01/01/hotwo-get-an-openshift-custom-ha-proxy-router

>>
FROM openshift/origin-haproxy-router

ADD haproxy-config.template  /var/lib/haproxy/conf/
# or you can use a diff name for the template.

#  Note: For the custom errorfiles, make sure you add those files in at the appropriate location.
#  Example:
#   ADD  custom/patrick/errors/400.http   /etc/haproxy/errors/400.http
ADD error-page-503.html /var/lib/haproxy/conf/
ADD error-page-502.html /var/lib/haproxy/conf/
WORKDIR  /var/lib/haproxy.conf

EXPOSE  80
ENV TEMPLATE_FILE=/var/lib/haproxy/conf/haproxy-config.template
# or use a custom name from above if needed.

ENV RELOAD_SCRIPT=/var/lib/haproxy/reload-haproxy
ENTRYPOINT ["/usr/bin/openshift-router"]
<<

Thank you and a happy new year!

Cheers
- Patrick 


Am 23.12.2015 um 23:31 schrieb Ram Ranganathan <rrangana redhat com>:

Hi Patrick,
    So if I understood this correctly, you wanted to create a MQTT service on OpenShift and then use the OpenShift router to
    send traffic to that service - hopefully got that right (its been one of those days!!).
   
    tdlr; version:  The recommended procedure would be to a build a customized image that is just like or similar to the
    openshift/{ose,origin}-haproxy-router image and then use that with the router command ala:
        oadm  router ... --images=patrick/haproxy-router


   The long version:  First build that image patrick/haproxy-router, you can do something like this:

      docker run --rm --interactive=true --tty --entrypoint=cat \
    registry.access.redhat.com/openshift3/ose-haproxy-router:v3.0.2.0 haproxy-config.template
 
   Step 2.  Edit that template to your specification - e.g. in your case, I think in this case (based on my looking at the 
                https://github.com/goern/haproxy-mqtt repo), its just adding some custom error files for  certain http 
                codes (400, 403, 408, 500-504), some global settings and some timeout changes and the meat of it is 
                a section for the mqtt bits (listen mqt).
                 So just add that to the appropriate place (global/default and a new section for listen mqt) in 
                 the OpenShift router template (haproxy-config.template)

  Step 3.  Create a docker file that derives from the openshift-ose-haproxy-router image. Assuming the modified haproxy 
               template is in a directory called custom/patrick/config/haproxy-config.template

$  cat > Dockerfile <<DEOF
    FROM  openshift-ose-haproxy-router   #  use the current image as the base.
    ADD custom/patrick/config/haproxy-config.template  /var/lib/haproxy/conf     #   or you can use a diff name for the template.

    #  Note: For the custom errorfiles, make sure you add those files in at the appropriate location.
    #  Example:
    #   ADD  custom/patrick/errors/400.http   /etc/haproxy/errors/400.http

    WORKDIR  /var/lib/haproxy.conf

    EXPOSE  80
    ENV TEMPLATE_FILE=/var/lib/haproxy/conf/haproxy-config.template   #   or use a custom name from above if needed.
    RELOAD_SCRIPT=/var/lib/haproxy/reload-config
    ENTRYPOINT ["/usr/bin/openshift-router"]

DEOF

   Assuming that you also want the routes configured in OpenShift to be serviced by this same router, the above image has
   an entrypoint that needs to be the openshift-router binary - so that it can feed in the routes from OpenShift store (etcd) to a 
   form that haproxy can consume (ala generate a haproxy.config file) as well as modify that config as routes/endpoints change. 


     Step 4.  Build the image for the dockerfile created above.
$  docker build -t  patrick/haproxy-router  ./


      Step 5.  Push the above image  patrick/haproxy-router   to your registry so that its available on all nodes. If its a single
                    node, you could probably get away by not doing this (not recommended but ... faster!!): 


    And then use that image to start the router.
     Step 6.  Run the router with your custom image:
            $   oadm  router ... --images=patrick/haproxy-router
       

HTH

Ram//
    

On Wed, Dec 23, 2015 at 4:44 AM, Patrick Breucking <me patrickbreucking de> wrote:
Hi!

I’m Patrick, i’m new in the OpenShift Origin world. I’m trying to setup an environment for IoT use cases. I deployed a Mqtt broker as service in Openshift origin and I would like to enable clients from the web to connect to the broker. As far as I understood I need to customize the HA proxy configuration for this (like this example https://github.com/goern/haproxy-mqtt).

I tried to follow the steps in your documentation (https://docs.openshift.com/enterprise/3.1/install_config/install/deploy_router.html#deploying-a-customized-haproxy-router).

In the step „Rebuild the Docker image to include your customized template“ you refer to a general instruction, but I miss the point how to derive/modify the original image „openshift3/ose-haproxy-router“ to include the customized template.

It would be very kind to give me a hint or enhance the documentation for this procedure.

Cheers
Patrick






_______________________________________________
users mailing list
users lists openshift redhat com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users




--
Ram//
main(O,s){s=--O;10<putchar(3^O?97-(15&7183>>4*s)*(O++?-1:1):10)&&\
main(++O,s++);}


Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]