How to reuse a server acorss multiple backends and have multiple backends for a frontend in HAproxy?

Viewed 128

Let's say I have the following configuration of frontends and backends in HAproxy:

frontend F1
  default_backend B1

frontend F2
  default_backend B2

frontend F3
  default_backend B3

frontend F_1_2
  default_backed B1 B2  # How to do this?

backend B1
  server serverB1_1 S:1001
  server serverB1_2 S:1002

backend B2
  server serverB2_1 S:1003
  server serverB2_2 S:1004

backend B3
  server serverB3_1 S:1001  # Reusing serverB1_1
  server serverB3_2 S:1003  # Reusing serverB2_1

I have two questions from the above configuration:

  1. How do I use both B1 and B2 for F3?
  2. How do I reuse the serverB1_1 and serverB2_1 in backend B3 instead of redefining it?
1 Answers

How do I use both B1 and B2 for F3?

Well the easiest solution is to add "B4" and add all servers there.
With a configuration management tool like ansible is this quite easy.

backend B4
  server serverB1_1 S:1001
  server serverB1_2 S:1002
  server serverB2_1 S:1003
  server serverB2_2 S:1004
  server serverB3_1 S:1001
  server serverB3_2 S:1003

How do I reuse the serverB1_1 and serverB2_1 in backend B3 instead of redefining it?

As far as I know is this not yet possible.
What you can do is to reuse the health checks from the other backends with the track function

Related