Forum Discussion

anujl_5566's avatar
anujl_5566
Icon for Nimbostratus rankNimbostratus
Jun 26, 2018

iRule to select between multiple pools based on cookie and still use persistence for default pool

Hello Community,

 

I have a use case where one of the applications is transitioning from one kind of application server to another. During this transition, I need an iRule to send traffic to a sub pool if the node that originally served the request is dead. So the flow will look like this -

 

  1. New Web request hits VS - APP_IN_Transition_VS:443. Default pool has nodes from both old and new app server stack. Cookie persistence is enabled. If the node that served the request stays up for the lifetime of cookie, nothing special needs to happen.
  2. Our CI/CD pipeline does a blue green deploy and now the default pool i mention above has different nodes from when the last request was served. In a scenario where all nodes are of same application server type, this won't be a problem as F5 will update the cookie with new node's IP. BUT in my case if the node that served the last request is dead post a deploy or some other reasons, I want the iRule to check for a custom cookie that was inserted by the APP and NOT by F5. So say cookie name is APP_S = Type_1 and APP_S = Type_2. I want the iRule to then select a pool based on this application cookie that was inserted by the application during initial request.

The sub pools cab be like Pool_Type_1 and Pool_Type_2 and Default_Pool will have nodes from both Type_1 and Type_2 pools.

 

Is it possible to do what i describe above.

 

Thanks

 

2 Replies

  • If the above problem does not make sense let me know i can try to break it down further. But i will appreciate any help.

     

  • You should be able to do this as part of a policy as it is computationally more efficient. However you could use an irule such as this to select your pools based on a cookie value:

    when HTTP_REQUEST {
        if {[HTTP::cookie exists "APP_S"]} {
            if {[HTTP::cookie value "APP_S" eq "Type_1"]} {
                pool Pool_Type_1
            } elseif {[HTTP::cookie value "APP_S" eq "Type_2"]} {
                pool Pool_Type_2 
            } else {
                pool Pool_default
            }
        }
    }