Forum Discussion

Mattews's avatar
Mattews
Icon for Cirrus rankCirrus
Jul 21, 2020

Create a Datagroup with URI:VIP:POOL relationship

Hi,

I need to create a datagroup with the relation in object (URI:VIP:POOL), this could help me to implement a dynamic iRule that, based on the HTTP REQUEST, redirects the traffic to a specific pool.

This is the starting point of the iRule:

when HTTP_REQUEST {
 
switch -glob [string tolower [HTTP::uri]] {
    "/def/ghi/account*" {
        pool  servers_8100
    }
    "/def/ghi/customer*" {
        pool servers_8200
    }
    "/def/ghi/equipment*" {
        pool servers_8300
    }
    "/def/ghi/order*" {
        pool servers_8400
    }
    "/def/ghi/statement*" {
        pool servers_8500
    }
    "/def/ghi/payment*" {
        pool servers_8600
    }
    "/def/ghi/financials*" {
        pool servers_8700
    }
    default {
        pool servers_default_pool
    }
}
}

Could you recommend to me a way for implementing both the datagroup and the iRule ?

Thanks in advance,

Matteo

  • HI Matteo, are you wanting to really redirect, or just to select the the appropriate pool? Can you give a sanitized example of the data-group goal, and how the client connects before/after the decision?

    • Mattews's avatar
      Mattews
      Icon for Cirrus rankCirrus

      The function/goal of the DG is to provide a correlation between URI:VIP:POOL, in this way I can direct two equals URI to different VIP dinamically, this is a common scenario in my production environment.

      The idea is that clients point to a specific VIP, based on URI the iRule invokes the DG (URI:VIP:POOL) and directs the traffic properly.

       

      I'm not able to provide you an example because I haven't try to do something like that.

       

      Do you have a suggestion about the iRule composition and the DG key:value parameters?

       

      Thanks

  • May be something like this, not tested,

    Irule:

    ltm rule /Common/VIP_URI_POOL_RULE {
    when HTTP_REQUEST {
    	set httpuri [string tolower [HTTP::uri]]
        set uri_pool [class match -value $httpuri contains VIP_URI_POOL_DGL]
    	if { $uri_pool ne "" } {
    		if { [active_members $uri_pool ] > 0 } {
    		pool $uri_pool
    		} else {
    		pool servers_fallback_pool
    		}
    	} else {
    	pool servers_default_pool
    	}
    }

    Data Group:

    ltm data-group internal VIP_URI_POOL_DGL {
        records {
    	"/def/ghi/account*" {
            data servers_8100
       }
        "/def/ghi/customer*" {
            data servers_8200
        }
        "/def/ghi/equipment*" {
            data servers_8300
        }
        "/def/ghi/order*" {
            data servers_8400
        }
        "/def/ghi/statement*" {
            data servers_8500
        }
        "/def/ghi/payment*" {
            data servers_8600
        }
        "/def/ghi/financials*" {
            data servers_8700
        }
        type string
    }
    }