CentOS 7: PCS Pacemaker Corosync Active/Active HAProxy dependency

clustercorosynchaproxypacemaker

I am trying to setup PCS for HAProxy on CentOS7 in an active/active configuration.
I've done active/active before, but I am not familiar with constraints and dependency groups.

So far so good:

 2 nodes configured
 4 resources configured

 Online: [ HOST1 HOST2 ]

 Full list of resources:

  Clone Set: VIPHA-clone [VIPHA] (unique)
      VIPHA:0     (ocf::heartbeat:IPaddr2):       Started HOST2
      VIPHA:1     (ocf::heartbeat:IPaddr2):       Started HOST1
  Clone Set: haproxy-clone [haproxy]
      Started: [ HOST2 HOST1 ]

However, now I'd like to add a constraint that HAPRoxy must be running in order for the IP to be served by a host:

pcs constraint order haproxy-clone then VIPHA-clone

The problem with this is, HAProxy will never start because it cannot bind to the IP unless it is started first.

How would I set this up so that:

  1. pcs will take the IP offline on a host if a health check (i.e. haproxy process running) fails?

  2. pcs will only bring the IP up if a health check (i.e. haproxy process running) succeeds?

    • If this isn't possible as described above, start at same time and behave as #1

I appreciate any input. Thank you!

Best Answer

I listen on a wildcard in haproxy.cfg

bind *:443

instead of

bind myvip:443

This way haproxy resource can run all the time whether the node has VIP resource or not. If node gets a VIP, haproxy will respond on it immediately.

The obvious side effect is that haproxy listens on all it's IP addresses not only on VIP.

If a port number conflicts (for example I need a differently configured port 443 on another IP or VIP), I define it as bind *:9443 and then put it behind a DNAT.

Related Topic