22.6. AWS での Ingress クラスタートラフィックの設定
OpenShift Container Platform は、クラスター内で実行されるサービスを使用してクラスター外からの通信を可能にする方法を提供します。この方法では、AWS のロードバランサー、具体的には Network Load Balancer (NLB) またはク Classic Load Balancer (CLB) を使用します。どちらのタイプのロードバランサーもクライアントの IP アドレスをノードに転送できますが、CLB にはプロキシープロトコルのサポートが必要です。これは OpenShift Container Platform によって自動的に有効になります。
NLB を使用するように Ingress Controller を設定するには、次の 2 つの方法があります。
-
現在 CLB を使用している Ingress Controller を強制的に置き換える。これにより、
IngressController
オブジェクトが削除され、新しい DNS レコードが伝達され、NLB がプロビジョニングされている間、停止が発生します。 -
CLB を使用する既存の Ingress Controller を編集して、NLB を使用する。これにより、
IngressController
オブジェクトを削除して再作成することなく、ロードバランサーが変更されます。
どちらの方法も、NLB から CLB への切り替えに使用できます。
これらのロードバランサーは、新規または既存の AWS クラスターで設定できます。
22.6.1. AWS での Classic Load Balancer タイムアウトの設定
OpenShift Container Platform は、特定のルートまたは Ingress Controller のカスタムタイムアウト期間を設定するためのメソッドを提供します。さらに、AWS Classic Load Balancer (CLB) には独自のタイムアウト期間があり、デフォルトは 60 秒です。
CLB のタイムアウト期間がルートタイムアウトまたは Ingress Controller タイムアウトよりも短い場合、ロードバランサーは接続を途中で終了する可能性があります。ルートと CLB の両方のタイムアウト期間を増やすことで、この問題を防ぐことができます。
22.6.1.1. ルートのタイムアウトの設定
Service Level Availability (SLA) で必要とされる、低タイムアウトが必要なサービスや、バックエンドでの処理速度が遅いケースで高タイムアウトが必要なサービスがある場合は、既存のルートに対してデフォルトのタイムアウトを設定することができます。
前提条件
- 実行中のクラスターでデプロイ済みの Ingress Controller が必要になります。
手順
oc annotate
コマンドを使用して、ルートにタイムアウトを追加します。$ oc annotate route <route_name> \ --overwrite haproxy.router.openshift.io/timeout=<timeout><time_unit> 1
- 1
- サポートされる時間単位は、マイクロ秒 (us)、ミリ秒 (ms)、秒 (s)、分 (m)、時間 (h)、または日 (d) です。
以下の例では、2 秒のタイムアウトを
myroute
という名前のルートに設定します。$ oc annotate route myroute --overwrite haproxy.router.openshift.io/timeout=2s
22.6.1.2. Classic Load Balancer タイムアウトの設定
Classic Load Balancer (CLB) のデフォルトのタイムアウトを設定して、アイドル接続を延長できます。
前提条件
- 実行中のクラスターにデプロイ済みの Ingress Controller がある。
手順
次のコマンドを実行して、デフォルト
ingresscontroller
の AWS 接続アイドルタイムアウトを 5 分に設定します。$ oc -n openshift-ingress-operator patch ingresscontroller/default \ --type=merge --patch='{"spec":{"endpointPublishingStrategy": \ {"type":"LoadBalancerService", "loadBalancer": \ {"scope":"External", "providerParameters":{"type":"AWS", "aws": \ {"type":"Classic", "classicLoadBalancer": \ {"connectionIdleTimeout":"5m"}}}}}}}'
オプション: 次のコマンドを実行して、タイムアウトのデフォルト値を復元します。
$ oc -n openshift-ingress-operator patch ingresscontroller/default \ --type=merge --patch='{"spec":{"endpointPublishingStrategy": \ {"loadBalancer":{"providerParameters":{"aws":{"classicLoadBalancer": \ {"connectionIdleTimeout":null}}}}}}}'
現在のスコープがすでに設定されている場合を除き、接続タイムアウト値を変更するには scope
フィールドを指定する必要があります。デフォルトのタイムアウト値に戻す場合は、scope
フィールドを設定する際に再度設定する必要はありません。
22.6.2. ネットワークロードバランサーを使用した AWS での Ingress クラスタートラフィックの設定
OpenShift Container Platform は、クラスター内で実行されるサービスを使用してクラスター外からの通信を可能にする方法を提供します。そのような方法の 1 つでは、Network Load Balancer (NLB) を使用します。NLB を新規または既存の AWS クラスターに設定することができます。
22.6.2.1. Ingress Controller を Classic Load Balancer から Network Load Balancer に切り替える
Classic Load Balancer (CLB) を使用している Ingress Controller を、AWS の Network Load Balancer (NLB) を使用する Ingress Controller に切り替えることができます。
これらのロードバランサーを切り替えても、IngressController
オブジェクトは削除されません。
この手順により、次の問題が発生する可能性があります。
- 新しい DNS レコードの伝播、新しいロードバランサーのプロビジョニング、およびその他の要因により、数分間続く可能性のある停止。この手順を適用すると、Ingress Controller ロードバランサーの IP アドレスや正規名が変更になる場合があります。
- サービスのアノテーションの変更により、ロードバランサーリソースがリークする。
手順
NLB を使用して切り替える既存の Ingress Controller を変更します。この例では、デフォルトの Ingress Controller に
External
スコープがあり、他のカスタマイズがないことを前提としています。ingresscontroller.yaml
ファイルの例apiVersion: operator.openshift.io/v1 kind: IngressController metadata: creationTimestamp: null name: default namespace: openshift-ingress-operator spec: endpointPublishingStrategy: loadBalancer: scope: External providerParameters: type: AWS aws: type: NLB type: LoadBalancerService
注記spec.endpointPublishingStrategy.loadBalancer.providerParameters.aws.type
フィールドの値を指定しない場合、Ingress Controller は、インストール時に設定されたクラスターIngress
設定のspec.loadBalancer.platform.aws.type
値を使用します。ヒントIngress Controller に、ドメインの変更など、更新したい他のカスタマイズがある場合は、代わりに Ingress Controller 定義ファイルを強制的に置き換えることを検討してください。
次のコマンドを実行して、Ingress Controller YAML ファイルに変更を適用します。
$ oc apply -f ingresscontroller.yaml
Ingress Controller の更新中は、数分間の停止が予想されます。
22.6.2.2. Network Load Balancer の使用から Classic Load Balancer への Ingress Controller の切り替え
Network Load Balancer (NLB) を使用している Ingress Controller を、AWS の Classic Load Balancer (CLB) を使用する Ingress Controller に切り替えることができます。
これらのロードバランサーを切り替えても、IngressController
オブジェクトは削除されません。
この手順により、新しい DNS レコードの伝播、新しいロードバランサーのプロビジョニング、およびその他の要因により、数分間続く停止が発生する可能性があります。この手順を適用すると、Ingress Controller ロードバランサーの IP アドレスや正規名が変更になる場合があります。
手順
CLB を使用して切り替える既存の Ingress Controller を変更します。この例では、デフォルトの Ingress Controller に
External
スコープがあり、他のカスタマイズがないことを前提としています。ingresscontroller.yaml
ファイルの例apiVersion: operator.openshift.io/v1 kind: IngressController metadata: creationTimestamp: null name: default namespace: openshift-ingress-operator spec: endpointPublishingStrategy: loadBalancer: scope: External providerParameters: type: AWS aws: type: Classic type: LoadBalancerService
注記spec.endpointPublishingStrategy.loadBalancer.providerParameters.aws.type
フィールドの値を指定しない場合、Ingress Controller は、インストール時に設定されたクラスターIngress
設定のspec.loadBalancer.platform.aws.type
値を使用します。ヒントIngress Controller に、ドメインの変更など、更新したい他のカスタマイズがある場合は、代わりに Ingress Controller 定義ファイルを強制的に置き換えることを検討してください。
次のコマンドを実行して、Ingress Controller YAML ファイルに変更を適用します。
$ oc apply -f ingresscontroller.yaml
Ingress Controller の更新中は、数分間の停止が予想されます。
22.6.2.3. Ingress Controller Classic Load Balancer の Network Load Balancer への置き換え
Classic Load Balancer (CLB) を使用している Ingress Controller は、AWS の Network Load Balancer (NLB) を使用している Ingress Controller に置き換えることができます。
この手順により、次の問題が発生する可能性があります。
- 新しい DNS レコードの伝播、新しいロードバランサーのプロビジョニング、およびその他の要因により、数分間続く可能性のある停止。この手順を適用すると、Ingress Controller ロードバランサーの IP アドレスや正規名が変更になる場合があります。
- サービスのアノテーションの変更により、ロードバランサーリソースがリークする。
手順
新しいデフォルトの Ingress Controller を含むファイルを作成します。以下の例では、デフォルトの Ingress Controller の範囲が
External
で、その他のカスタマイズをしていないことを想定しています。ingresscontroller.yml
ファイルの例apiVersion: operator.openshift.io/v1 kind: IngressController metadata: creationTimestamp: null name: default namespace: openshift-ingress-operator spec: endpointPublishingStrategy: loadBalancer: scope: External providerParameters: type: AWS aws: type: NLB type: LoadBalancerService
デフォルトの Ingress Controller が他にカスタマイズされている場合には、それに応じてファイルを修正してください。
ヒントIngress Controller に他のカスタマイズがなく、ロードバランサータイプのみを更新する場合は、「Ingress Controller を Classic Load Balancer から Network Load Balancer に切り替える」に記載の手順に従ってください。
Ingress Controller の YAML ファイルを強制的に置き換えます。
$ oc replace --force --wait -f ingresscontroller.yml
Ingress Controller の置き換えが完了するまでお待ちください。数分間の停止が予想されます。
22.6.2.4. 既存 AWS クラスターでの Ingress Controller ネットワークロードバランサーの設定
AWS Network Load Balancer (NLB) がサポートする Ingress Controller を既存のクラスターに作成できます。
前提条件
- AWS クラスターがインストールされている。
インフラストラクチャーリソースの
PlatformStatus
は AWS である必要があります。PlatformStatus
が AWS であることを確認するには、以下を実行します。$ oc get infrastructure/cluster -o jsonpath='{.status.platformStatus.type}' AWS
手順
既存のクラスターの AWS NLB がサポートする Ingress Controller を作成します。
Ingress Controller のマニフェストを作成します。
$ cat ingresscontroller-aws-nlb.yaml
出力例
apiVersion: operator.openshift.io/v1 kind: IngressController metadata: name: $my_ingress_controller1 namespace: openshift-ingress-operator spec: domain: $my_unique_ingress_domain2 endpointPublishingStrategy: type: LoadBalancerService loadBalancer: scope: External3 providerParameters: type: AWS aws: type: NLB
クラスターにリソースを作成します。
$ oc create -f ingresscontroller-aws-nlb.yaml
新規 AWS クラスターで Ingress Controller NLB を設定する前に、インストール設定ファイルの作成 手順を完了する必要があります。
22.6.2.5. 新規 AWS クラスターでの Ingress Controller ネットワークロードバランサーの設定
新規クラスターに AWS Network Load Balancer (NLB) がサポートする Ingress Controller を作成できます。
前提条件
-
install-config.yaml
ファイルを作成し、これに対する変更を完了します。
手順
新規クラスターの AWS NLB がサポートする Ingress Controller を作成します。
インストールプログラムが含まれるディレクトリーに切り替え、マニフェストを作成します。
$ ./openshift-install create manifests --dir <installation_directory> 1
- 1
<installation_directory>
については、クラスターのinstall-config.yaml
ファイルが含まれるディレクトリーの名前を指定します。
cluster-ingress-default-ingresscontroller.yaml
という名前のファイルを<installation_directory>/manifests/
ディレクトリーに作成します。$ touch <installation_directory>/manifests/cluster-ingress-default-ingresscontroller.yaml 1
- 1
<installation_directory>
については、クラスターのmanifests/
ディレクトリーが含まれるディレクトリー名を指定します。
ファイルの作成後は、以下のようにいくつかのネットワーク設定ファイルが
manifests/
ディレクトリーに置かれます。$ ls <installation_directory>/manifests/cluster-ingress-default-ingresscontroller.yaml
出力例
cluster-ingress-default-ingresscontroller.yaml
エディターで
cluster-ingress-default-ingresscontroller.yaml
ファイルを開き、必要な Operator 設定を記述するカスタムリソース (CR) を入力します。apiVersion: operator.openshift.io/v1 kind: IngressController metadata: creationTimestamp: null name: default namespace: openshift-ingress-operator spec: endpointPublishingStrategy: loadBalancer: scope: External providerParameters: type: AWS aws: type: NLB type: LoadBalancerService
-
cluster-ingress-default-ingresscontroller.yaml
ファイルを保存し、テキストエディターを終了します。 -
オプション:
manifests/cluster-ingress-default-ingresscontroller.yaml
ファイルをバックアップします。インストールプログラムは、クラスターの作成時にmanifests/
ディレクトリーを削除します。
22.6.2.6. LoadBalancerService Ingress Controller の作成時にサブネットを選択する
既存クラスター内の Ingress Controller のロードバランサーサブネットを手動で指定できます。デフォルトでは、ロードバランサーのサブネットは AWS によって自動的に検出されます。しかし、Ingress Controller でサブネットを指定すると、これがオーバーライドされ、手動で制御できるようになります。
前提条件
- AWS クラスターがインストールされている。
-
IngressController
をマッピングするサブネットの名前または ID がわかっている。
手順
カスタムリソース (CR) ファイルを作成します。
次の内容の YAML ファイル (例:
sample-ingress.yaml
) を作成します。apiVersion: operator.openshift.io/v1 kind: IngressController metadata: namespace: openshift-ingress-operator name: <name> spec: domain: <domain> endpointPublishingStrategy: type: LoadBalancerService loadBalancer: scope: External dnsManagementPolicy: Managed
カスタムリソース (CR) ファイルを作成します。
YAML ファイルにサブネットを追加します。
apiVersion: operator.openshift.io/v1 kind: IngressController metadata: name: <name> 1 namespace: openshift-ingress-operator spec: domain: <domain> 2 endpointPublishingStrategy: type: LoadBalancerService loadBalancer: scope: External providerParameters: type: AWS aws: type: Classic classicLoadBalancer: 3 subnets: ids: 4 - <subnet> 5 - <subnet> - <subnet> dnsManagementPolicy: Managed
- 1
<name>
は、IngressController
の名前に置き換えます。- 2
<domain>
は、IngressController
によって提供される DNS 名に置き換えます。- 3
- NLB を使用する場合は、
networkLoadBalancer
フィールドを使用することもできます。 - 4
- 必要に応じて、ID でサブネットを指定する代わりに、
names
フィールドを使用して名前でサブネットを指定することもできます。 - 5
- サブネット ID (
names
を使用する場合は名前) を指定します。重要アベイラビリティーゾーンごとに最大 1 つのサブネットを指定できます。外部 Ingress Controller にはパブリックサブネットだけを指定し、内部 Ingress Controller にはプライベートサブネットだけを指定してください。
CR ファイルを適用します。
ファイルを保存し、OpenShift CLI (
oc
) を使用して適用します。$ oc apply -f sample-ingress.yaml
IngressController
の状態を確認して、ロードバランサーが正常にプロビジョニングされたことを確認します。$ oc get ingresscontroller -n openshift-ingress-operator <name> -o jsonpath="{.status.conditions}" | yq -PC
22.6.2.7. 既存の Ingress Controller のサブネットを更新する
OpenShift Container Platform で手動で指定したロードバランサーサブネットを使用して IngressController
を更新することで、システム停止を回避し、サービスの安定性を維持し、ネットワーク設定を特定の要件に準拠させることができます。次の手順では、新しいサブネットを選択して適用し、設定の変更を検証し、ロードバランサーのプロビジョニングが成功したことを確認する方法を示します。
この手順により、新しい DNS レコードの伝播、新しいロードバランサーのプロビジョニング、およびその他の要因により、数分間の停止が発生する可能性があります。この手順を適用すると、Ingress Controller ロードバランサーの IP アドレスや正規名が変更になる場合があります。
手順
手動で指定したロードバランサーサブネットを使用して IngressController
を更新するには、次の手順に従います。
既存の IngressController を変更して、新しいサブネットに更新します。
apiVersion: operator.openshift.io/v1 kind: IngressController metadata: name: <name> 1 namespace: openshift-ingress-operator spec: domain: <domain> 2 endpointPublishingStrategy: type: LoadBalancerService loadBalancer: scope: External providerParameters: type: AWS aws: type: Classic 3 classicLoadBalancer: 4 subnets: ids: 5 - <updated_subnet> 6 - <updated_subnet> - <updated_subnet>
重要アベイラビリティーゾーンごとに最大 1 つのサブネットを指定できます。外部 Ingress Controller にはパブリックサブネットだけを指定し、内部 Ingress Controller にはプライベートサブネットだけを指定してください。
次のコマンドを実行して、
IngressController
のProgressing
状態を調べ、サブネットの更新を適用する方法について確認します。$ oc get ingresscontroller -n openshift-ingress-operator subnets -o jsonpath="{.status.conditions[?(@.type==\"Progressing\")]}" | yq -PC
出力例
lastTransitionTime: "2024-11-25T20:19:31Z" message: 'One or more status conditions indicate progressing: LoadBalancerProgressing=True (OperandsProgressing: One or more managed resources are progressing: The IngressController subnets were changed from [...] to [...]. To effectuate this change, you must delete the service: `oc -n openshift-ingress delete svc/router-<name>`; the service load-balancer will then be deprovisioned and a new one created. This will most likely cause the new load-balancer to have a different host name and IP address and cause disruption. To return to the previous state, you can revert the change to the IngressController: [...]' reason: IngressControllerProgressing status: "True" type: Progressing
- 更新を適用するために、次のコマンドを実行して、Ingress Controller に関連付けられているサービスを削除します。
$ oc -n openshift-ingress delete svc/router-<name>
検証
ロードバランサーが正常にプロビジョニングされたことを確認するには、次のコマンドを実行して
IngressController
の状態を確認します。$ oc get ingresscontroller -n openshift-ingress-operator <name> -o jsonpath="{.status.conditions}" | yq -PC
22.6.3. 関連情報
- ネットワークのカスタマイズによる AWS へのクラスターのインストール。
- NLB のサポートの詳細は、Network Load Balancer support on AWS を参照してください。
- CLB のプロキシープロトコルサポートの詳細は、Configure proxy protocol support for your Classic Load Balancer を参照してください。