Forum Discussion

Kevin_Knox's avatar
Kevin_Knox
Icon for Nimbostratus rankNimbostratus
Aug 21, 2019

IRule needs to read a pool and see its members

I'm new to this stuff, and I'm likely not thinking in an LTM-ic way yet, but I want to give my developers the ability to hit a specific node within a VIP by supplying the node name in the host header, and I'd like this ability to be reusable across VIPs. Policies require that I know all the moving parts ahead of time, so I've decided to start by trying to create an iRule. In HTTP_REQUEST, I can pull the pool name, and I have the member name in the host header. Now, I need to convert the member name into an IP address and get the port, then I can use the pool command to do exactly what I want. I've proven this works, when I can get the IP and port. Our target servers use a wide variety of ports, so I need to read it from the particular pool in use by each different virtual server.

 

I should be able to convert the member name into an IP address using RESOLV::lookup. I've not gotten it to work yet, but it should. I ran into a bigger problem, though, trying to get the target node's port number.

 

I can find no way to read the port number of the target server until the LB_SELECTED event, at which time I can no longer change the selection.

[LB::server pool] works in HTTP_REQUEST, but [LB::server port] is empty until it's too late. Given the qualified name of the pool, I'd think the iRule code could read the contents of the pool configuration somehow, but if it's out there I can't find it. If I could read the contents of the pool definition in the HTTP_REQUEST method, I'd be golden because every member listens on the same port.

 

While I'm waiting and thinking, I've gotten my developers on the road using a site-specific traffic policy. I know I can do this with policies, but I want an iRule I can just attach to a given virtual server at time of need and detach when the developers are done.

2 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    You can embed the port number information in the name of the pool/member and then parse the name in your irule.

    • Kevin_Knox's avatar
      Kevin_Knox
      Icon for Nimbostratus rankNimbostratus

      Thank you, JG. I'd found no other way, but hoped someone out here could see a way forward. I'll keep this possibility in my hip pocket. Thank you, again.