Irule to select pool in a complicated failover scenario
So long story long...we've an application in PROD and STG environments which has servers setup to handle traffic for 3 services (let us say A,B,C)
--------------- ---------------
PROD STG
--------------- ---------------
A_PROD_SRVR_1 A_STG_SRVR_1
A_PROD_SRVR_2 A_STG_SRVR_2
B_PROD_SRVR_1 B_STG_SRVR_1
B_PROD_SRVR_2 B_STG_SRVR_2
C_PROD_SRVR_1 C_STG_SRVR_1
C_PROD_SRVR_2 C_STG_SRVR_2
Set of requirements from the application to work are as follows :
1) Incoming PROD traffic for any service (A,B or C) should be load balanced between PROD servers (1 & 2) for that service
2) Incoming STG traffic for any service (A,B or C) should be load balanced between PROD servers (1 & 2) for that service
3) If both SRVR1 and SRVR2 for any of the services A, B or C are unreachable, then all the incoming PROD traffic for all the services (A and B and C) should be handled by STG servers.
For example, if B_PROD_SRVR_1 and B_PROD_SRVR_2 are down, then the PROD traffic for service A should be handled by A_STG_SRVR_1 and A_STG_SRVR_2 and PROD traffic for service B should be handled by B_STG_SRVR_1 and B_STG_SRVR_2 and PROD traffic for service C should be handled by C_STG_SRVR_1 and C_STG_SRVR_2
Also, We're not running multiple services on any server. So we've in total 12 different servers here and ports for each service A,B,C is different to each other
I'm completely new to Irules and though I started learning recently, I'm still a long way away from writing a working irule for scenarios like this, hence reaching out to the community for help. Any suggestions or ideas is much appreciated!