on 21-Jun-2019 08:12
Problem this snippet solves:
I share with you one special load balancing scenario that I had to deal with.
Topology:
Requirements:
How to use this snippet:
It's easy to configure. You need to configure a virtual server without default pool and this iRule applied to it.
Considerations:
Remove Table Variable:
For deleting the table variable you can replace the irule for this one and execute it once.
when CLIENT_ACCEPTED { table delete -all -subtable "[virtual name]" log local0. "[virtual name] table was deleted" }
You can also define a timeout value for the variable instead of using indefinite.
REF - https://devcentral.f5.com/s/articles/v101-the-table-command-advanced-data-expiration
Code :
when CLIENT_ACCEPTED { # PICK THE LAST POOL SELECTION set selection [table lookup -subtable "[virtual name]" pool_selection] # EVAL POOL SELECTION if { [active_members] == 0 } { set selection " " table replace -subtable "[virtual name]" pool_selection $selection } elseif { [active_members ] == 0 } { set selection " " table replace -subtable "[virtual name]" pool_selection $selection } elseif { [active_members ] < 3 } { set selection " " table replace -subtable "[virtual name]" pool_selection $selection } # APPLY POOL SELECTION switch $selection { " " { pool } " " { pool } default { pool table set -subtable "[virtual name]" pool_selection indefinite indefinite } } }
Tested this on version:
12.1Hello.
I've noticed the code is not correct. There is some info missed. You can use this link instead.
https://github.com/DariuSGB/F5_iRules/blob/master/LB_2Pools.tcl