API method

You can use the API method to determine the best performing GSLB service. The API method for GSLB uses a REST API to determine the best performing GSLB service.

In the API method, when GSLB receives a DNS request from a client, it evaluates the request against the specified rule. If GSLB encounters the HTTP callout expression, SYS.HTTP_CALLOUT(<name>), it invokes a REST API request to an HTTP callout agent. GSLB uses the response from the HTTP callout agent to decide the best performing service. In the DNS response, GSLB returns the IP address of the best performing service, back to the client.

To configure a GSLB API method by using the CLI

Perform the following to configure the GSLB API method:

  1. Configure an HTTP callout. For more information, see Configuring an HTTP callout.

    At the command prompt, type:

    add policy httpCallout <name> [-IPAddress <ip_addr|ipv6_addr>] [-port <port>] [-vServer <string>] [-returnType <returnType>] [-httpMethod (GET | POST)] [-hostExpr <string>] [-urlStemExpr <string>] [-headers <name(value)> ...] [-parameters <name(value)> ...] [-bodyExpr <string>] [-fullReqExpr <string>] [-scheme (http | https)] [-resultExpr <string>] [-cacheForSecs <secs>] [-comment <string>]
    

    Example:

    add policy httpCallout GSLB_Method_API -IPAddress 208.111.39.237 -port 443 -returnType TEXT -hostExpr “\”hopx.gslb.com\“” -urlStemExpr “\”/zones/1/customers/92395/apps/6/decision\“” -headers Authorization(“Basic 19fbe6db-4332-4e3f-a8bc-ee47bdc726f8") -parameters ip(DNS.REQ.OPT.ECS.IP.TYPECAST_TEXT_T ALT CLIENT.IP.SRC.TYPECAST_TEXT_T) -scheme https -resultExpr “HTTP.RES.BODY(HTTP.RES.CONTENT_LENGTH).XPATH_JSON(xp%/providers/Val[1]/provider%)” -cacheForSecs 30
    
  2. Specify the API method for load balancing. GSLB evaluates the DNS request against the specified rule.

    At the command prompt, type:

    add gslb vserver <name> <serviceType>  [-lbMethod <lbMethod>] [-backupLBMethod <backupLBMethod>] -rule <expression>
    

    Example:

    add gslb vserver vs1 HTTP -lbMethod API -backupLBMethod ROUNDROBIN -rule “sys.http_callout(GSLB_Method_API)”