Forum Discussion
Master toggle and nested pools?
We have a need to have two sets of pools. An active and a passive group of pools. The idea our management has is that one pool will be active, the other passive, and we can deploy code to the passive pools and cut over to it once tested. The problem I am having is that we have multiple pools. So what I would love to do is nest a pool such that an iRule references some master pool and that master pool then toggles which sub pool is used. For instance
Master - use grouped pool A or B
Pool group A: Ruby Pool A, PHP Pool A, Python Pool A
Pool group B: Ruby Pool B, PHP Pool B, Python Pool A
Then there would need to be some way in the iRULE to define a pool class. Say we have a pool class called RubyWeb... this means to use Ruby Pool A or Ruby Pool B depending on what the master says is active.
Again, the hope is that I can change which pool group is used in a single place rather than having to go back through 100 iRules and change things from say Ruby Pool A to Ruby Pool B in one place, PHP Pool A to PHP Pool B in another place etc.
Can you make some sort of master nested toggle mechanism like this? Or am I thinking about this in the wrong way?
3 Replies
- nitass
Employee
can we just use static global variable something like this?
e.g.[root@ve10:Active] config b virtual bar list virtual bar { snat automap destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when RULE_INIT { set static::pool PoolA } when HTTP_REQUEST { pool foo$static::pool } when HTTP_RESPONSE { log local0. "client [IP::client_addr]:[TCP::client_port] server [IP::server_addr]:[TCP::server_port] pool [LB::server pool]" } } [root@ve10:Active] config b pool fooPoolA list pool fooPoolA { members 200.200.200.101:80 {} } [root@ve10:Active] config b pool fooPoolB list pool fooPoolB { members 200.200.200.111:80 {} } [root@ve10:Active] config tail -f /var/log/ltm Mar 21 00:29:25 local/tmm info tmm[4950]: Rule myrule : client 172.28.19.251:46491 server 200.200.200.101:80 pool fooPoolA - Bubbagump_12531
Nimbostratus
Ok, so I am not sure how global variables work in F5. How do I call $static::pool in other iRules and then what is the scope of that variable? So long as it is active under the VirtualServer will all iRules inherit/understand the value given to static::pool?
So my thinking is under the virtual server I have an iRule:
root@ve10:Active] config b rule GlobalSwitch list
rule GlobalSwitch {
when RULE_INIT {
set static::pool A
}
Then in say all of my 100 other various other iRules I can say?
when HTTP_REQUEST {
if { ([HTTP::host] matches "www.siteabc.com")} {
pool /Common/pool_Ruby_$static::pool
}
}
And they will inherit the value given in the above "GlobalSwitch" iRule?
Am I understanding correctly?Do I even need to bind the global variable iRule to anything? This:
https://devcentral.f5.com/wiki/irules.RULE_INIT.ashx
leads me to believe that I just need to define it and not bind it to anything.
Thanks! - nitass
Employee
Then in say all of my 100 other various other iRules I can say?
when HTTP_REQUEST {
if { ([HTTP::host] matches "www.siteabc.com")} {
pool /Common/pool_Ruby_$static::pool
}
}yes
And they will inherit the value given in the above "GlobalSwitch" iRule?
Am I understanding correctly?yes, you are right.
Do I even need to bind the global variable iRule to anything? This:
https://devcentral.f5.com/wiki/irules.RULE_INIT.ashx
leads me to believe that I just need to define it and not bind it to anything.yes, RULE_INIT event does not need to assign to virtual server.
iRules 101 - 03 - Variables by Colin
https://devcentral.f5.com/tech-tips/articles/irules-101-03-variables
v.10 - A new iRules Namespace by Colin
https://devcentral.f5.com/tech-tips/articles/v10-a-new-irules-namespace
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com