NSX Edge LB の API 操作を体験してみる。Part 3(One-Arm LB の設定)

NSX Edge LB の API 操作を体験してみる。Part 3(One-Arm LB の設定)

NSX Edge ロードバランサ(LB)を NSX API で設定変更してみます。


概要については、こちらをどうぞ。

NSX Edge LB の API 操作を体験してみる。Part 1(はじめに)


前回の投稿はこちらです。

NSX Edge LB の API 操作を体験してみる。Part 2(NSX Edge のデプロイ)


手順について。


今回は、前回デプロイした NSX Edge LB の設定をします。

  1. LB の有効化
  2. アプリケーション プロファイルの作成
  3. LB モニタの設定変更
  4. バックエンド プールの作成とメンバの追加
  5. 仮想サーバの作成

1. LB の有効化


前回デプロイした NSX Edge(ID は edge-5)で LB を有効化します。

この時点では、まだ LB が無効な状態です。

nsxapi-lb-p3-01.png

XML ファイル(edge-onearm-lb-enable.txt)を作成します。

LB 有効化のため、loadBalancer 直下の enable 要素を true にします。

Edge Service Gateway としてデプロイされた NSX Edge にデフォルトで作成されている

LB モニタ(monitor-1 ~ monitor-3)は、XML ではデフォルトの値を指定しておきます。

cat <<EOF > edge-onearm-lb-enable.txt

<loadBalancer>

  <enabled>true</enabled>

  <monitor>

    <monitorId>monitor-1</monitorId>

    <type>tcp</type>

    <interval>5</interval>

    <timeout>15</timeout>

    <maxRetries>3</maxRetries>

    <name>default_tcp_monitor</name>

  </monitor>

  <monitor>

    <monitorId>monitor-2</monitorId>

    <type>http</type>

    <interval>5</interval>

    <timeout>15</timeout>

    <maxRetries>3</maxRetries>

    <method>GET</method>

    <url>/</url>

    <name>default_http_monitor</name>

  </monitor>

  <monitor>

    <monitorId>monitor-3</monitorId>

    <type>https</type>

    <interval>5</interval>

    <timeout>15</timeout>

    <maxRetries>3</maxRetries>

    <method>GET</method>

    <url>/</url>

    <name>default_https_monitor</name>

  </monitor>

</loadBalancer>

EOF

XML ファイルを読み込んで、NSX Edge 「edge-5」の LB 設定を有効にします。

cat edge-onearm-lb-enable.txt | curl -k -s -u admin:VMware1! -X PUT -H 'Content-type: text/xml' -d @- https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config

Web Client での確認でも、LB が有効な状態になりました。

nsxapi-lb-p3-02.png


2. アプリケーション プロファイルの作成

アプリケーション プロファイルを作成します。

  • 名前: OneArmWeb-01
  • タイプ: HTTPS
  • SSL パススルーの有効化

XML ファイル(app-prof.txt)を作成します。

cat <<EOF > app-prof.txt

  <applicationProfile>

  <name>OneArmWeb-01</name>

  <insertXForwardedFor>false</insertXForwardedFor>

  <sslPassthrough>true</sslPassthrough>

  <template>HTTPS</template>

  <serverSslEnabled>false</serverSslEnabled>

</applicationProfile>

EOF

XML ファイルを読み込んで、API でアプリケーション プロファイルを作成します。

cat app-prof.txt | curl -k -s -u admin:VMware1! -X POST -H 'Content-type: text/xml' -d @- https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/applicationprofiles

アプリケーション プロファイルが applicationProfile-1 として作成されました。

nsxapi-lb-p3-03.png

API でも、アプリケーション プロファイルを確認できます。

curl -k -s -u admin:VMware1! -X GET https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/applicationprofiles | xmllint --format -

3. LB モニタの設定変更

ラボの環境にあわせて、サービス監視をする LB モニタの設定を変更します。


HTTPS モニタは default_https_monitor で、ID は monitor-3 です。

この時点では、モニタ対象の URL が「/」になっているので、ラボの環境に合わせて/cgi-bin/hol.cgi」に変更します。

nsxapi-lb-p3-04.png

XML ファイル(mon-https.txt)を作成します。

cat <<EOF > mon-https.txt

<monitor>

  <monitorId>monitor-3</monitorId>

  <type>https</type>

  <interval>5</interval>

  <timeout>15</timeout>

  <maxRetries>3</maxRetries>

  <method>GET</method>

  <url>/cgi-bin/hol.cgi</url>

  <name>default_https_monitor</name>

</monitor>

EOF

モニタを設定変更します。

cat mon-https.txt | curl -k -s -u admin:VMware1! -X PUT -H 'Content-type: text/xml' -d @- https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/monitors/monitor-3

設定変更されました。

nsxapi-lb-p3-05.png

API でも確認できます。

curl -k -s -u admin:VMware1! -X GET https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/monitors/monitor-3 | xmllint --format -

4. バックエンド プールの作成とメンバの追加

LB による振り分け先となるサーバ(メンバ)をまとめるプールを作成します。

ここでは、プールのメンバ(Web サーバ 2台)も同時に指定します。

プール

  • 名前: Web-Tier-Pool-01
  • モニタ: default_https_monitor → monitor-3

メンバ1

  • 名前: web-01a
  • IP 172.16.10.11
  • ポート: 443
  • モニタ ポート: 443

メンバ2

  • 名前: web-02a
  • IP 172.16.10.12
  • ポート: 443
  • モニタ ポート: 443

上記の内容で XML ファイル(pool-web-tier.txt)を作成します。

cat <<EOF > pool-web-tier.txt

<pool>

  <name>Web-Tier-Pool-01</name>

  <description></description>

  <transparent>false</transparent>

  <algorithm>round-robin</algorithm>

  <monitorId>monitor-3</monitorId>

  <member>

    <ipAddress>172.16.10.11</ipAddress>

    <weight>1</weight>

    <port>443</port>

    <name>web-01a</name>

    <monitorPort>443</monitorPort>

  </member>

  <member>

    <ipAddress>172.16.10.12</ipAddress>

    <weight>1</weight>

    <port>443</port>

    <name>web-02a</name>

    <monitorPort>443</monitorPort>

  </member>

</pool>

EOF

プールを作成します。

cat pool-web-tier.txt | curl -k -s -u admin:VMware1! -X POST -H 'Content-type: text/xml' -d @- https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/pools

プールが作成されました。今回作成されたプールの ID は、pool-1 です。

nsxapi-lb-p3-06.png

作成したプールは、API でも確認できます。

curl -k -s -u admin:VMware1! -X GET https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/pools | xmllint --format -

5. 仮想サーバの作成

LB の仮想サーバを作成します。

ここでの「仮想サーバ」は VM のことではなく、VIP やプロトコル、ポート番号などを指定した LB の設定のことです。

  • 名前: Web-Tier-VIP-01
  • アプリケーション プロファイル: OneArmWeb-01 → applicationProfile-1
  • IP アドレス: 172.16.10.10
  • プロトコル: HTTPS
  • ポート: 443
  • デフォルト プール: Web-Tier-Pool-01 → pool-1


XML ファイル(vs-web-tier.txt)を作成します。

cat <<EOF > vs-web-tier.txt

<virtualServer>

  <name>Web-Tier-VIP-01</name>

  <enabled>true</enabled>

  <ipAddress>172.16.10.10</ipAddress>

  <protocol>https</protocol>

  <port>443</port>

  <connectionLimit>0</connectionLimit>

  <connectionRateLimit>0</connectionRateLimit>

  <applicationProfileId>applicationProfile-1</applicationProfileId>

  <defaultPoolId>pool-1</defaultPoolId>

  <enableServiceInsertion>false</enableServiceInsertion>

  <accelerationEnabled>false</accelerationEnabled>

</virtualServer>

EOF


仮想サーバを作成します。

cat vs-web-tier.txt | curl -k -s -u admin:VMware1! -X POST -H 'Content-type: text/xml' -d @- https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/virtualservers


仮想サーバが作成されました。

nsxapi-lb-p3-07.png


下記の API でも、仮想サーバの確認ができます。

curl -k -s -u admin:VMware1! -X GET https://192.168.110.15/api/4.0/edges/edge-5/loadbalancer/config/virtualservers | xmllint --format -

これで、「One-Arm Load Bala...」のテストページが表示できるようになります。

nsxapi-lb-p3-08.png


つづく。

NSX Edge LB の API 操作を体験してみる。Part 4(LB メンバのステータス確認)


Version history
Revision #:
1 of 1
Last update:
‎05-15-2016 05:04 AM
Updated by: