Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tweak Openshift's haproxy.cfg using a file in my scalable app's git repository?

I would like to maintain some haproxy.cfg customizations for my scalable OpenShift application in git, and have Openshift pick up and use my settings on deployment.

Is this possible?

I know that Openshift generates the haproxy settings in that file. Ideally I would be able to change the httpchk url or disable the public haproxy-status page, and have Openshift merge my config with the server-provided settings.

like image 477
Gabriel Bauman Avatar asked Mar 20 '23 16:03

Gabriel Bauman


2 Answers

Yes you can do that

  • SSH into your application gear using rhc ssh --app <app_name>
  • Change directory to haproxy/conf
  • change the following in haproxy.cfg option httpchk GET / to option httpchk GET /api/v1/ping
  • Restart the HAProxy cartridge from your local machine using RHC rhc cartridge-restart --cartridge haproxy

For more read my blog https://www.openshift.com/blogs/how-to-host-your-java-ee-application-with-auto-scaling

like image 153
Shekhar Avatar answered May 02 '23 19:05

Shekhar


I know the question is a bit old, but maybe it will help someone else. You can use rhc scp command to download and upload any file to your main gear:

  • download the file from your gear: rhc scp APPNAME download . haproxy/conf/haproxy.cfg

  • edit it

  • upload the file back to your gear: rhc scp APPNAME upload haproxy.cfg haproxy/conf/haproxy.cfg

You can also:

  • add your haproxy configuration file to your git repo (e.g. conf/haproxy.cfg)
  • add an action hook script to your .openshift/action_hooks git directory (e.g. pre_reload, pre_restart) like so:
    #!/bin/bash
    cp $OPENSHIFT_REPO_DIR/conf/haproxy.cfg ~/haproxy/conf/haproxy.cfg
    
  • Don't forget to make it executable (git update-index --chmod=+x .openshift/action_hooks/*)
like image 24
Piotr Kuciapski Avatar answered May 02 '23 21:05

Piotr Kuciapski