本番ドメインから始める代わりに、テスト用またはステージング用のドメインでロードバランサーを作成することを推奨します。インフラの構成によっては、モニターやプールを一時的に変更する場合があります。
テストドメインから始めると、本番トラフィックを流す前に、すべてが正しく動作していることを確認できます。
プールは、ロードバランサーの作成ワークフロー 内、または Pools タブで作成できます。
-
Load Balancing を開きます。
-
Pools タブを選び、Create pool を選びます。
-
プールについて、次の情報を入力します。
- 名前(一意である必要があります)
- 名前の詳細を説明する説明
- Endpoint Steering の選択。プールが各エンドポイントへトラフィックをルーティングする方法に影響します
-
各エンドポイントについて、次の情報を入力します。
- 名前(一意である必要があります)
- エンドポイントのアドレス、または関連するホスト名
- (任意)Virtual Network。エンドポイントがプライベート IP アドレスの場合は必須です。
- Weight
- (任意)Add host header を選んで ホスト名 を指定します
- (任意)トラフィックの送信先ポート
-
プール内の追加エンドポイントについても、この手順を繰り返します。
-
(任意)プールに Proximity Steering 用の座標を設定します。
-
プールで、次の情報を更新します。
- Health Threshold:
Health Threshold は、プール全体を Healthy とみなし、ロードバランサーのプール順に従ってトラフィックを受け取るために必要な、健全なエンドポイント数です。この数を大きくするとプールの信頼性は上がりますが、unhealthy にもなりやすくなります。
- Monitor: モニター を関連付けます
- Health Monitor Regions: プールのヘルスを 複数のロケーション から確認するかどうかを選びます。精度は上がりますが、エンドポイントへのプローブトラフィックが発生することがあります
- Pool Notifications: プールの有効化・無効化、またはプールやエンドポイントの ヘルスステータス の変化を通知するアラートを、新規作成または既存の確認ができます。
- Health Threshold:
-
完了したら、Save を選びます。
プロパティの一覧は Create Pool を参照してください。API 認証のヘルプは Cloudflare API ドキュメント を参照してください。
Required API token permissions
At least one of the following token permissions is required:Load Balancing: Monitors and Pools Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/load_balancers/pools" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"description": "Primary data center - Provider XYZ",
"name": "primary-dc-1",
"enabled": false,
"load_shedding": {
"default_percent": 0,
"default_policy": "random",
"session_percent": 0,
"session_policy": "hash"
},
"minimum_origins": 2,
"monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc",
"check_regions": [
"WEU",
"ENAM"
],
"origins": [
{
"name": "app-server-1",
"address": "0.0.0.0",
"enabled": true,
"weight": 0.56,
"header": {
"Host": [
"example.com"
]
}
}
],
"origin_steering": {
"policy": "random"
},
"notification_filter": {
"origin": {
"disable": false,
"healthy": null
},
"pool": {
"disable": false,
"healthy": null
}
}
}'レスポンスには、新しいプールの完全な定義が含まれます。
{
"success": true,
"errors": [],
"messages": [],
"result": {
"id": "17b5962d775c646f3f9725cbc7a53df4",
"created_on": "2021-01-01T05:20:00.12345Z",
"modified_on": "2021-01-01T05:20:00.12345Z",
"description": "Primary data center - Provider XYZ",
"name": "primary-dc-1",
"enabled": false,
"load_shedding": {
"default_percent": 0,
"default_policy": "random",
"session_percent": 0,
"session_policy": "hash"
},
"minimum_origins": 2,
"monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc",
"check_regions": [
"WEU",
"ENAM"
],
"origins": [
{
"name": "app-server-1",
"address": "0.0.0.0",
"enabled": true,
"weight": 0.56,
"header": {
"Host": [
"example.com"
]
}
}
],
"origin_steering": {
"policy": "random"
},
"notification_filter": {
"origin": {
"disable": false,
"healthy": null
},
"pool": {
"disable": false,
"healthy": null
}
}
}
}プールを作成したあと、次のパラメーターを指定して 新しい通知を作成 することも必要です。
"alert_type": "load_balancing_health_alert",
"filters": {
"pool_id": <<ARRAY_OF_INCLUDED_POOL_IDS>>,
"new_health": <<ARRAY_OF_STATUS_TRIGGERS>> ["Unhealthy", "Healthy"],
"event_source": <<ARRAY_OF_OBJECTS_WATCHED>> ["pool", "origin"]
}