Forum Discussion
iRule for Version check with dependent pool selection
I may not have fully understood but here is a simple iRule I've put together which may work, or at least give you an idea of where to go next. Unfortunately there is no why to interrogate the result of a health monitor by an iRule but you can can determine if you have active members - which is reliant on the monitor.
From what I understand, incoming requests will have the version number in the URI and from that you want to dynamically select the pool or pool member.
If you have a one to one relationship between pool names and version you can dynamically select the pool based on URI - you will however have to maintain a different pool for every new version.
when HTTP_REQUEST {
set defaultPool "MY_DEFAULT_POOL_NAME"
use getfield to pick 'field1'of the URI https://host.com/field1/field2
set dynamicPool [getfield [HTTP::uri] "/" 2]
log local0. "Pool: $dynamicPool derived from URI"
if {$dynamicPool ne ""} {
place commands using dynamicPool in catch statement
this will silently catch the TCL error in the event
the pool doesn't exist
if {[catch {
if {[active_members $dynamicPool] > 0} {
log local0. "load balancing to pool: $dynamicPool"
pool $dynamicPool
}
} catchErr ]} {
select default pool if dynamicPool doesn't exist
log local0. "unable to select pool based on URI, will use default - error: $catchErr'"
pool $defaultPool
}
} else {
log local0. "Error - pool value empty, setting to default"
pool $defaultPool
}
}
Please note this iRule has only tested for syntax errors
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