StyleBook to create a load balancing virtual server
Header
name: lb-vserver
description: This StyleBook defines a load balancing virtual server configuration.
display-name: Load Balancing Virtual Server (HTTP)
namespace: com.example.stylebooks
schema-version: "1.0"
version: "0.1"
-
name: A name for this StyleBook.
-
description: A description defining what this StyleBook does. This description appears on NetScaler® ADM.
-
display-name: A descriptive name for the StyleBook that appears on NetScaler ADM.
-
namespace: A namespace forms part of a unique identifier for a StyleBook to avoid name collisions.
-
schema-version: Always takes the value “1.0” in this release.
-
version: The version number of the StyleBook. You can change the version number when you update the StyleBook.
Import StyleBooks
import-stylebooks:
-
namespace: netscaler.nitro.config
prefix: ns
version: "10.5"
Parameters
parameters:
-
name: name
type: string
label: Application Name
description: Name of the application configuration.
required: true
-
name: ip
type: ipaddress
label: Application Virtual IP (VIP)
description: Application VIP that the clients access.
required: true
-
name: lb-alg
type: string
label: LoadBalancing Algorithm
description: Choose the load balancing algorithm (method) used for load balancing client request between the application servers.
allowed-values:
- ROUNDROBIN
- LEASTCONNECTION
default: ROUNDROBIN
-
type. Type of value these parameters can take. For example, name and lb-alg can take a string value and the ip value has to be of type ip address. Parameters in a StyleBook can be of any of the following built-in types:
-
string. An array of characters. If a length is not specified, the string value can take any number of characters. However, you can limit the length of a string type by using the attributes min-length and max-length.
-
number. An integer number. You can specify the minimum and maximum number that this type can take by using the attributes min-value and max-value.
-
boolean. Can be either true or false. Also, note that all the literals are considered by YAML as booleans (for example, Yes or No).
-
ipaddress. A string that represents a valid IPv4 or IPv6 address.
-
tcp-port. A number between 0 and 65535 that represents a TCP or UDP port.
-
password. An opaque/secret string value. When NetScaler ADM displays a value for this parameter, it is shown as asterisks (*****).
-
certfile. Certificate file.
-
keyfile. Certificate private key file.
-
file. A parameter of this type requires the user to upload a file, for example, a certificate or key file.
-
object. Consists of multiple elements and each of these elements is a parameter. This type can be used to group multiple related parameters under one parent parameter.
-
required. States whether a parameter is mandatory or optional. If it is set to true, the parameter is mandatory and the user has to provide a value for this parameter when creating configurations using this StyleBook. By default, all parameters are optional. In this example, name and ip are mandatory parameters while lb-alg is an optional parameter, the default value of which is "ROUNDROBIN."
Components
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.name
servicetype: HTTP
ipv46: $parameters.ip
port: 80
lbmethod: $parameters.lb-alg
-
Built-in type. This type is provided by the system and you do not have to define it, for example, the NITRO entity types “lbvserver” or “servicegroup.” In this example, you are using a built-in component type.
-
Composite type. This type is the StyleBook that you created and imported into NetScaler ADM, or the default StyleBook that is shipped with NetScaler ADM. You can learn more about composite StyleBooks in Create a Composite StyleBook.
Build your StyleBook
name: lb-vserver
namespace: com.example.stylebook
version: "1.0"
display-name: Load Balancing Virtual Server (HTTP)
description: "This stylebook defines a very simple load balancing HTTP virtual server configuration"
schema-version: "1.0"
import-stylebooks:
-
namespace: netscaler.nitro.config
version: "10.5"
prefix: ns
-
namespace: com.citrix.adc.stylebooks
version: "1.0"
prefix: stlb
parameters:
-
name: name
label: "Application Name"
description: "Give a name to the application configuration."
type: string
required: true
-
name: vip-ipaddress
label: "Load Balancer IP Address"
description: "The Application VIP that clients access"
type: ipaddress
required: true
-
name: lb-alg
label: LB Algorithm
description: Load Balancing Algorithm
type: string
default: ROUNDROBIN
allowed-values:
- ROUNDROBIN
- LEAST-CONNECTION
components:
-
name: lbvserver-comp
description: This StyleBook component (a Builtin Nitro StyleBook) builds a NetScaler load balancing virtual server configuration object.
type: ns::lbvserver
properties:
name: $parameters.name
ipv46: $parameters.vip-ipaddress
lbmethod: $parameters.lb-alg
servicetype: HTTP
port: 80