1.18.13.2. フェイルオーバー用の DestinationRule の設定
以下を設定する DestinationRule リソースを作成します。
- サービスの外れ値の検出。これは、フェイルオーバーを正しく機能させるには必要です。特に、サービスのエンドポイントが異常である場合には把握できるようにサイドカープロキシーを設定し、最終的に次のローカリティへのフェイルオーバーをトリガーします。
- リージョン間のフェイルオーバーポリシー。これにより、リージョンの境界を超えたフェイルオーバーが予測どおりに動作することが保証されます。
手順
cluster-adminロールを持つユーザーとして OpenShift Container Platform CLI にログインします。以下のコマンドを入力します。次に、プロンプトが表示されたら、ユーザー名とパスワードを入力します。$ oc login --username=<NAMEOFUSER> <API token> https://<HOSTNAME>:6443Service Mesh コントロールプレーンをインストールしたプロジェクトに変更します。
$ oc project <smcp-system>たとえば、
green-mesh-systemです。$ oc project green-mesh-system次の例に基づいて
DestinationRuleファイルを作成します。ここで、green-mesh が使用できない場合、トラフィックはus-eastリージョンの green-mesh からus-westの red-mesh にルーティングされます。DestinationRuleの例apiVersion: networking.istio.io/v1beta1 kind: DestinationRule metadata: name: default-failover namespace: bookinfo spec: host: "ratings.bookinfo.svc.cluster.local" trafficPolicy: loadBalancer: localityLbSetting: enabled: true failover: - from: us-east to: us-west outlierDetection: consecutive5xxErrors: 3 interval: 10s baseEjectionTime: 1mDestinationRuleをデプロイします。次のコマンドを入力します。<DestinationRule>にはファイルへのフルパスを追加します。$ oc create -n <application namespace> -f <DestinationRule.yaml>以下に例を示します。
$ oc create -n bookinfo -f green-mesh-us-west-DestinationRule.yaml