基本的なロードバランシング構成を作成するためのStyleBook
ヘッダー
name: basic-lb-config
namespace: com.example.stylebooks
version: "0.1"
display-name: Load Balancing Configuration
description: This StyleBook defines a simple load balancing configuration.
schema-version: "1.0"
StyleBookのインポート
import-stylebooks:
-
namespace: netscaler.nitro.config
prefix: ns
version: "10.5"
パラメータ
name、ip、および lb-alg は変更されません。
parameters:
-
name: name
type: string
label: Application Name
description: Give a name to the application configuration.
required: true
-
name: ip
type: ipaddress
label: Application Virtual IP (VIP)
description: The Application VIP that clients access
required: true
-
name: lb-alg
type: string
label: LoadBalancing Algorithm
description: Choose the loadbalancing algorithm (method) used for loadbalancing client requests between the application servers.
allowed-values:
- ROUNDROBIN
- LEASTCONNECTION
default: ROUNDROBIN
-
name: svc-servers
type: ipaddress[]
label: Application Server IPs
description: The IP addresses of all the servers of this application
required: true
-
name: svc-port
type: tcp-port
label: Server Port
description: The TCP port open on the application servers to receive requests.
default: 80
コンポーネント
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.name + "-lb"
servicetype: HTTP
ipv46: $parameters.ip
port: 80
lbmethod: $parameters.lb-alg
components:
-
name: svcg-comp
type: ns::servicegroup
properties:
name: $parameters.name + "-svcgrp"
servicetype: HTTP
components:
-
name: lbvserver-svg-binding-comp
type: ns::lbvserver_servicegroup_binding
properties:
name: $parent.parent.properties.name
servicegroupname: $parent.properties.name
-
name: members-svcg-comp
type: ns::servicegroup_servicegroupmember_binding
repeat: $parameters.svc-servers
repeat-item: srv
properties:
ip: $srv
port: str($parameters.svc-port)
servicegroupname: $parent.properties.name
servicegroup の属性に指定された値を使用して、NetScalerインスタンス上にサービスグループを作成するために使用されます。この例では、servicetype に静的な値を指定していますが、name は入力パラメータから値を取得します。パラメータセクションで定義されているパラメータ name は、$parameters.name + "-svcgrp" という表記を使用して参照されます。ここで "-svcgrp" はユーザー定義の名前に付加(連結)されます。
lbvserver) の間に構成オブジェクトをバインドするために使用されます。$parent 表記(親参照とも呼ばれます)は、親コンポーネント内のエンティティを参照するために使用されます。たとえば、servicegroupname: $parent.properties.name は親コンポーネント svcg-comp によって作成されたサービスグループを参照し、name: $parent.parent.properties.name は親の親コンポーネント lbvserver-comp によって作成された仮想サーバーを参照します。
srv と呼ばれます)に対して servicegroup_servicegroupmember_binding 型の NITRO 構成オブジェクトを作成し、各 NITRO 構成オブジェクトの ip 属性を対応するサーバーの IP アドレスに設定します。
srv) を割り当てて、反復処理中の現在の値を指定できます。この変数名は、同じコンポーネントのプロパティまたは子コンポーネントで $<varname> として参照されます(例: $srv)。
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.name + "-lb"
servicetype: HTTP
ipv46: $parameters.ip
port: 80
lbmethod: $parameters.lb-alg
-
name: svcg-comp
type: ns::servicegroup
properties:
servicegroupname: $parameters.name + "-svcgrp"
servicetype: HTTP
-
name: lbvserver-svg-binding-comp
type: ns::lbvserver_servicegroup_binding
properties:
name: $components.lbvserver-comp.properties.name
servicegroupname: $components.svcg-comp.properties.servicegroupname
-
name: members-svcg-comp
type: ns::servicegroup_servicegroupmember_binding
repeat: $parameters.svc-servers
repeat-item: srv
properties:
ip: $srv
port: 80
servicegroupname: $components.svcg-comp.properties.servicegroupname
lb-bindings、app-name、rewrite-config などです。もう1つの慣例は、コンポーネント名に -comp 文字列を接尾辞として付けることです。
出力
lbvserver および servicegroup 構成オブジェクトを公開するように指定できます。
outputs:
-
name: lbvserver-comp
value: $components.lbvserver-comp
description: The component that builds the Nitro lbvserver configuration object
-
name: servicegroup-comp
value: $components.svcg-comp
description: The component that builds the Nitro servicegroup configuration object
StyleBookを構築する
name: basic-lb-config
namespace: com.example.stylebooks
version: "0.1"
display-name: Load Balancing Configuration
description: This StyleBook defines a simple load balancing configuration.
schema-version: "1.0"
import-stylebooks:
-
namespace: netscaler.nitro.config
version: "10.5"
prefix: ns
parameters:
-
name: name
type: string
label: Application Name
description: Give a name to the application configuration.
required: true
-
name: ip
type: ipaddress
label: Application Virtual IP (VIP)
description: The Application VIP that clients access
required: true
-
name: lb-alg
type: string
label: LoadBalancing Algorithm
description: Choose the loadbalancing algorithm (method) used for loadbalancing client requests between the application servers.
allowed-values:
- ROUNDROBIN
- LEASTCONNECTION
default: ROUNDROBIN
-
name: svc-servers
type: ipaddress[]
label: Application Server IPs
description: The IP addresses of all the servers of this application
required: true
-
name: svc-port
type: tcp-port
label: Server Port
description: The TCP port open on the application servers to receive requests.
default: 80
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: $parameters.name + "-lb"
servicetype: HTTP
ipv46: $parameters.ip
port: 80
lbmethod: $parameters.lb-alg
-
name: svcg-comp
type: ns::servicegroup
properties:
servicegroupname: $parameters.name + "-svcgrp"
servicetype: HTTP
-
name: lbvserver-svg-binding-comp
type: ns::lbvserver_servicegroup_binding
properties:
name: $components.lbvserver-comp.properties.name
servicegroupname: $components.svcg-comp.properties.servicegroupname
-
name: members-svcg-comp
type: ns::servicegroup_servicegroupmember_binding
repeat: $parameters.svc-servers
repeat-item: srv
properties:
ip: $srv
port: 80
servicegroupname: $components.svcg-comp.properties.servicegroupname
outputs:
-
name: lbvserver-comp
value: $components.lbvserver-comp
description: The component that builds the Nitro lbvserver configuration object
-
name: servicegroup-comp
value: $components.svcg-comp
description: The component that builds the Nitro servicegroup configuration object