OpenShift Service Mesh 3.0 is a Technology Preview feature only
Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. This documentation is a work in progress and might not be complete or fully tested.5.3. マルチプライマリーマルチネットワークメッシュのインストール
2 つの OpenShift Container Platform クラスターのマルチプライマリーマルチネットワークトポロジーに Istio をインストールします。
この手順では、CLUSTER1
は East クラスター、CLUSTER2
は West クラスターです。
これらの手順は、2 つ以上のクラスターにまたがるメッシュに適応できます。
前提条件
- メッシュに含まれるすべてのクラスターに OpenShift Service Mesh 3 Operator をインストールしている。
- 「マルチクラスターメッシュの証明書の作成」を完了している。
- 「ルチクラスタートポロジーへの証明書の適用」を完了している。
- Istio Container Network Interface (CNI) リソースを作成している。
-
これらの手順を実行するために使用できるノートパソコンに
istioctl
がインストールされている。
手順
以下のコマンドを実行して、インストールする Istio バージョンを定義する
ISTIO_VERSION
環境変数を作成します。$ export ISTIO_VERSION=1.24.1
Istio を East クラスターにインストールします。
次のコマンドを実行して、East クラスターに
Istio
リソースを作成します。$ cat <<EOF | oc --context "${CTX_CLUSTER1}" apply -f - apiVersion: sailoperator.io/v1alpha1 kind: Istio metadata: name: default spec: version: v${ISTIO_VERSION} namespace: istio-system values: global: meshID: mesh1 multiCluster: clusterName: cluster1 network: network1 EOF
次のコマンドを実行して、コントロールプレーンが
Ready
ステータス状態を返すまで待機します。$ oc --context "${CTX_CLUSTER1}" wait --for condition=Ready istio/default --timeout=3m
次のコマンドを実行して、East クラスターに East-West ゲートウェイを作成します。
$ oc --context "${CTX_CLUSTER1}" apply -f https://raw.githubusercontent.com/istio-ecosystem/sail-operator/main/docs/multicluster/east-west-gateway-net1.yaml
次のコマンドを実行して、ゲートウェイを介してサービスを公開します。
$ oc --context "${CTX_CLUSTER1}" apply -n istio-system -f https://raw.githubusercontent.com/istio-ecosystem/sail-operator/main/docs/multicluster/expose-services.yaml
Istio を West クラスターにインストールします。
次のコマンドを実行して、West クラスターに
Istio
リソースを作成します。$ cat <<EOF | oc --context "${CTX_CLUSTER2}" apply -f - apiVersion: sailoperator.io/v1alpha1 kind: Istio metadata: name: default spec: version: v${ISTIO_VERSION} namespace: istio-system values: global: meshID: mesh1 multiCluster: clusterName: cluster2 network: network2 EOF
次のコマンドを実行して、コントロールプレーンが
Ready
ステータス状態を返すまで待機します。$ oc --context "${CTX_CLUSTER2}" wait --for condition=Ready istio/default --timeout=3m
次のコマンドを実行して、West クラスターに East-West ゲートウェイを作成します。
$ oc --context "${CTX_CLUSTER2}" apply -f https://raw.githubusercontent.com/istio-ecosystem/sail-operator/main/docs/multicluster/east-west-gateway-net2.yaml
次のコマンドを実行して、ゲートウェイを介してサービスを公開します。
$ oc --context "${CTX_CLUSTER2}" apply -n istio-system -f https://raw.githubusercontent.com/istio-ecosystem/sail-operator/main/docs/multicluster/expose-services.yaml
次のコマンドを実行して、West クラスターの API サーバーへのアクセスを提供する East クラスターにリモートシークレットをインストールします。
$ istioctl create-remote-secret \ --context="${CTX_CLUSTER2}" \ --name=cluster2 | \ oc --context="${CTX_CLUSTER1}" apply -f -
次のコマンドを実行して、East クラスターの API サーバーへのアクセスを提供する West クラスターにリモートシークレットをインストールします。
$ istioctl create-remote-secret \ --context="${CTX_CLUSTER1}" \ --name=cluster1 | \ oc --context="${CTX_CLUSTER2}" apply -f -
5.3.1. マルチクラスタートポロジーの確認
サンプルアプリケーションをデプロイし、2 つの OpenShift Container Platform クラスターのマルチクラスタートポロジーでトラフィックを確認します。
この手順では、CLUSTER1
は East クラスター、CLUSTER2
は West クラスターです。
前提条件
- メッシュに含まれるすべてのクラスターに OpenShift Service Mesh Operator をインストールしている。
- 「マルチクラスターメッシュの証明書の作成」を完了している。
- 「ルチクラスタートポロジーへの証明書の適用」を完了している。
- Istio Container Network Interface (CNI) リソースを作成している。
-
これらの手順を実行するために使用するノートパソコンに
istioctl
がインストールされている。 - マルチクラスタートポロジーがインストールされている。
手順
East クラスターにサンプルアプリケーションをデプロイします。
次のコマンドを実行して、East クラスター上にサンプルアプリケーション namespace を作成します。
$ oc --context "${CTX_CLUSTER1}" get project sample || oc --context="${CTX_CLUSTER1}" new-project sample
以下のコマンドを実行して、サイドカーインジェクションをサポートするようにアプリケーション namespace にラベルを付けます。
$ oc --context="${CTX_CLUSTER1}" label namespace sample istio-injection=enabled
helloworld
アプリケーションをデプロイします。以下のコマンドを実行して
helloworld
サービスを作成します。$ oc --context="${CTX_CLUSTER1}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/helloworld/helloworld.yaml \ -l service=helloworld -n sample
以下のコマンドを実行して
helloworld-v1
デプロイメントを作成します。$ oc --context="${CTX_CLUSTER1}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/helloworld/helloworld.yaml \ -l version=v1 -n sample
次のコマンドを実行して、
sleep
アプリケーションをデプロイします。$ oc --context="${CTX_CLUSTER1}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/sleep/sleep.yaml -n sample
次のコマンドを実行して、East クラスターの
helloworld
アプリケーションがReady
ステータス状態を返すまで待機します。$ oc --context="${CTX_CLUSTER1}" wait --for condition=available -n sample deployment/helloworld-v1
次のコマンドを実行して、East クラスターの
sleep
アプリケーションがReady
ステータス状態を返すまで待機します。$ oc --context="${CTX_CLUSTER1}" wait --for condition=available -n sample deployment/sleep
West クラスターにサンプルアプリケーションをデプロイします。
次のコマンドを実行して、West クラスターにサンプルアプリケーション namespace を作成します。
$ oc --context "${CTX_CLUSTER2}" get project sample || oc --context="${CTX_CLUSTER2}" new-project sample
以下のコマンドを実行して、サイドカーインジェクションをサポートするようにアプリケーション namespace にラベルを付けます。
$ oc --context="${CTX_CLUSTER2}" label namespace sample istio-injection=enabled
helloworld
アプリケーションをデプロイします。以下のコマンドを実行して
helloworld
サービスを作成します。$ oc --context="${CTX_CLUSTER2}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/helloworld/helloworld.yaml \ -l service=helloworld -n sample
以下のコマンドを実行して、
helloworld-v2
デプロイメントを作成します。$ oc --context="${CTX_CLUSTER2}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/helloworld/helloworld.yaml \ -l version=v2 -n sample
次のコマンドを実行して、
sleep
アプリケーションをデプロイします。$ oc --context="${CTX_CLUSTER2}" apply \ -f https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/samples/sleep/sleep.yaml -n sample
次のコマンドを実行して、West クラスターの
helloworld
アプリケーションがReady
ステータス状態を返すまで待機します。$ oc --context="${CTX_CLUSTER2}" wait --for condition=available -n sample deployment/helloworld-v2
次のコマンドを実行して、West クラスターの
sleep
アプリケーションがReady
ステータス状態を返すまで待機します。$ oc --context="${CTX_CLUSTER2}" wait --for condition=available -n sample deployment/sleep
クラスター間のトラフィックフローの確認
East クラスターの場合は、次のコマンドを実行して、
helloworld
サービスに 10 個のリクエストを送信します。$ for i in {0..9}; do \ oc --context="${CTX_CLUSTER1}" exec -n sample deploy/sleep -c sleep -- curl -sS helloworld.sample:5000/hello; \ done
両方のクラスターからの応答が表示されていることを確認します。つまり、サービスのバージョン 1 とバージョン 2 が応答で確認できます。
West クラスターの場合は、
helloworld
サービスに 10 個のリクエストを送信します。$ for i in {0..9}; do \ oc --context="${CTX_CLUSTER2}" exec -n sample deploy/sleep -c sleep -- curl -sS helloworld.sample:5000/hello; \ done
両方のクラスターからの応答が表示されていることを確認します。つまり、サービスのバージョン 1 とバージョン 2 が応答で確認できます。
5.3.2. 開発環境からのマルチクラスタートポロジーの削除
開発環境でマルチクラスター機能を試した後、すべてのクラスターからマルチクラスタートポロジーを削除します。
この手順では、CLUSTER1
は East クラスター、CLUSTER2
は West クラスターです。
前提条件
- マルチクラスタートポロジーがインストールされている。
手順
次のコマンドを実行して、Istio とサンプルアプリケーションを開発環境の East クラスターから削除します。
$ oc --context="${CTX_CLUSTER1}" delete istio/default ns/istio-system ns/sample ns/istio-cni
次のコマンドを実行して、Istio とサンプルアプリケーションを開発環境の West クラスターから削除します。
$ oc --context="${CTX_CLUSTER2}" delete istio/default ns/istio-system ns/sample ns/istio-cni