Application Delivery Management

複合StyleBookの作成

StyleBookの重要で強力な機能の1つは、他のStyleBookの構成要素として使用できることです。StyleBookは別のStyleBookにインポートでき、Nitro組み込みStyleBookと同様に、2番目のStyleBookのコンポーネントによって使用されるタイプとして参照できます。

例えば、前のセクションで作成したbasic-lb-config StyleBookを使用して、composite-exampleという別のStyleBookを構築できます。”basic-lb-config” StyleBookを使用するには、新しいStyleBookのimport-stylebooksセクションでインポートする必要があります。

StyleBookの構築

新しいStyleBookは次のようになります。

name: composite-example
namespace: com.example.stylebooks
version: "0.1"
display-name: Load Balancing Virtual Server (HTTP/RoundRobin)
description: This StyleBook defines a RoundRobin load balancing configuration with a monitor.
schema-version: "1.0"
import-stylebooks:
  -
   namespace: netscaler.nitro.config
   version: "10.5"
   prefix: ns
  -
   namespace: com.example.stylebooks
   version: "0.1"
   prefix: stlb
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: svc-servers
    type: ipaddress[]
    label: Application Server IPs
    description: The IP addresses of all the servers of this application
    required: true

  -
    name: response-code
    type: string[]
    label: List of Response Codes
    description: List of Response Codes - Provide a list of response codes in integer.

components:
  -
    name: basic-lb-comp
    type: stlb::basic-lb-config
    description: This component's type is another StyleBook that builds the NetScaler lbvserver, servicegroups and services configuration objects.
    properties:
     name: $parameters.name
     ip: $parameters.ip
     svc-servers: $parameters.svc-servers
  -
     name: monit-comp
     type: ns::lbmonitor
     description: This component is a basic Nitro type (a Builtin StyleBook) that builds the NetScaler monitor configuration object.
     properties:
       monitorname: $parameters.name + "-mon"
       type: HTTP
       respcode: $parameters.response-code
       httprequest: "'GET /'"
       lrtm: ENABLED
       secure: "YES"

     components:
        -
          name: monit-svcgrp-bind-comp
          type: ns::servicegroup_lbmonitor_binding
          properties:
            servicegroupname: $components.basic-lb-comp.outputs.servicegroup-comp.properties.servicegroupname
            monitor_name: $parent.properties.monitorname
<!--NeedCopy-->

import-stylebooksセクションでは、basic-lb-config StyleBookをその名前空間とバージョンを使用してインポートし、”stlb”というプレフィックスで参照します。

componentsセクションでは、2つのコンポーネントが定義されています。最初のコンポーネントはstlb::basic-lb-configタイプです。ここで、”basic-lb-config”は、基本的な負荷分散構成を作成するためのStyleBookで作成したStyleBookの名前です。このコンポーネントに定義されているプロパティは、basic-lb-config StyleBookで宣言されている必須パラメーターに対応しています。ただし、StyleBookの任意のパラメーター(必須およびオプションの両方)を使用できます。lbvserver、サービスグループ、およびサービスとサービスグループのバインディングを再構築する代わりに、これらすべてを行うStyleBookをコンポーネントとしてインポートし、新しいStyleBookでこれらの構成オブジェクトを作成するために使用します。

StyleBookは、Nitroリソース”lbmonitor”(組み込みStyleBook)の属性を使用してモニター構成オブジェクトを作成する2番目のコンポーネント”monit-comp”を追加します。また、モニターを最初のコンポーネントで作成されたサービスグループにバインドするバインディング構成オブジェクトを作成するためのサブコンポーネント”monit-svcgrp-bind-comp”も持っています。”basic-lb-config” StyleBookで作成されたサービスグループコンポーネントが出力として公開されているため、このStyleBookは、式$components.basic-lb-comp.outputs.servicegroup-compを使用してそれにアクセスできます。これは、インポートするStyleBookが、そうでなければアクセスできなかったインポートされたStyleBook内のコンポーネントにアクセスするために、outputsセクションをどのように使用できるかを示す例です。

次に、StyleBookの内容をテキストエディターにコピーして貼り付け、ファイルをcomposite-example.yamlとして保存します。NetScaler Consoleにファイルをインポートする前に、YAMLコンテンツを検証してください。その後、NetScaler Consoleにインポートし、このStyleBookを使用して1つまたは複数の構成を作成します。

YAMLコンテンツを検証およびインポートするには、StyleBookの組み込みYAMLバリデーターを使用することをお勧めします。

複合StyleBookの作成