5.2. マルチクラスター設定の概要
マルチクラスタートポロジーを設定するには、次のアクションを実行する必要があります。
- 各クラスターに OpenShift Service Mesh Operator をインストールします。
- 各クラスターのルート証明書と中間証明書を作成するか、それらにアクセスできるようにします。
- 各クラスターにセキュリティー証明書を適用します。
- 各クラスターに Istio をインストールします。
5.2.1. マルチクラスタートポロジー用の証明書の作成 リンクのコピーリンクがクリップボードにコピーされました!
2 つのクラスターのルート証明書と中間認証局 (CA) 証明書を作成します。
前提条件
- OpenSSL がローカルにインストールされている。
手順
ルート CA 証明書を作成します。
次のコマンドを実行して、ルート証明書のキーを作成します。
$ openssl genrsa -out root-key.pem 4096ルート CA 証明書用に、
root-ca.confという名前の OpenSSL 設定証明書ファイルを作成します。ルート証明書設定ファイルの例
encrypt_key = no prompt = no utf8 = yes default_md = sha256 default_bits = 4096 req_extensions = req_ext x509_extensions = req_ext distinguished_name = req_dn [ req_ext ] subjectKeyIdentifier = hash basicConstraints = critical, CA:true keyUsage = critical, digitalSignature, nonRepudiation, keyEncipherment, keyCertSign [ req_dn ] O = Istio CN = Root CA次のコマンドを実行して証明書署名要求を作成します。
$ openssl req -sha256 -new -key root-key.pem \ -config root-ca.conf \ -out root-cert.csr次のコマンドを実行して、共有ルート証明書を作成します。
$ openssl x509 -req -sha256 -days 3650 \ -signkey root-key.pem \ -extensions req_ext -extfile root-ca.conf \ -in root-cert.csr \ -out root-cert.pem
East クラスターの中間 CA 証明書を作成します。
次のコマンドを実行して、
eastという名前のディレクトリーを作成します。$ mkdir east次のコマンドを実行して、East クラスターの中間証明書のキーを作成します。
$ openssl genrsa -out east/ca-key.pem 4096East クラスターの中間証明書用に、
east/ディレクトリーに、intermediate.confという名前の OpenSSL 設定ファイルを作成します。次のサンプルファイルをコピーしてローカルに保存します。設定ファイルのサンプル
[ req ] encrypt_key = no prompt = no utf8 = yes default_md = sha256 default_bits = 4096 req_extensions = req_ext x509_extensions = req_ext distinguished_name = req_dn [ req_ext ] subjectKeyIdentifier = hash basicConstraints = critical, CA:true, pathlen:0 keyUsage = critical, digitalSignature, nonRepudiation, keyEncipherment, keyCertSign subjectAltName=@san [ san ] DNS.1 = istiod.istio-system.svc [ req_dn ] O = Istio CN = Intermediate CA L = east次のコマンドを実行して証明書署名要求を作成します。
$ openssl req -new -config east/intermediate.conf \ -key east/ca-key.pem \ -out east/cluster-ca.csr次のコマンドを実行して、East クラスターの中間 CA 証明書を作成します。
$ openssl x509 -req -sha256 -days 3650 \ -CA root-cert.pem \ -CAkey root-key.pem -CAcreateserial \ -extensions req_ext -extfile east/intermediate.conf \ -in east/cluster-ca.csr \ -out east/ca-cert.pem次のコマンドを実行して、east クラスターの中間 CA 証明書とルート CA 証明書から証明書チェーンを作成します。
$ cat east/ca-cert.pem root-cert.pem > east/cert-chain.pem && cp root-cert.pem east
West クラスターの中間 CA 証明書を作成します。
次のコマンドを実行して、
westという名前のディレクトリーを作成します。$ mkdir west次のコマンドを実行して、West クラスターの中間証明書のキーを作成します。
$ openssl genrsa -out west/ca-key.pem 4096West クラスターの中間証明書用に、
west/ディレクトリーにintermediate.confという名前の OpenSSL 設定ファイルを作成します。次のサンプルファイルをコピーしてローカルに保存します。設定ファイルのサンプル
[ req ] encrypt_key = no prompt = no utf8 = yes default_md = sha256 default_bits = 4096 req_extensions = req_ext x509_extensions = req_ext distinguished_name = req_dn [ req_ext ] subjectKeyIdentifier = hash basicConstraints = critical, CA:true, pathlen:0 keyUsage = critical, digitalSignature, nonRepudiation, keyEncipherment, keyCertSign subjectAltName=@san [ san ] DNS.1 = istiod.istio-system.svc [ req_dn ] O = Istio CN = Intermediate CA L = west次のコマンドを実行して証明書署名要求を作成します。
$ openssl req -new -config west/intermediate.conf \ -key west/ca-key.pem \ -out west/cluster-ca.csr次のコマンドを実行して証明書を作成します。
$ openssl x509 -req -sha256 -days 3650 \ -CA root-cert.pem \ -CAkey root-key.pem -CAcreateserial \ -extensions req_ext -extfile west/intermediate.conf \ -in west/cluster-ca.csr \ -out west/ca-cert.pem次のコマンドを実行して証明書チェーンを作成します。
$ cat west/ca-cert.pem root-cert.pem > west/cert-chain.pem && cp root-cert.pem west
5.2.2. マルチクラスタートポロジーへの証明書の適用 リンクのコピーリンクがクリップボードにコピーされました!
マルチクラスタートポロジー内のクラスターにルートおよび中間認証局 (CA) 証明書を適用します。
この手順では、CLUSTER1 は East クラスター、CLUSTER2 は West クラスターです。
前提条件
- 外部ロードバランサーをサポートする 2 つの OpenShift Container Platform クラスターにアクセスできる。
- 各クラスターのルート CA 証明書と中間 CA 証明書を自分で作成したか、またはそれらが誰かによって用意されている。
手順
マルチクラスタートポロジーの East クラスターに証明書を適用します。
次のコマンドを実行して、East クラスターにログインします。
$ oc login -u https://<east_cluster_api_server_url>次のコマンドを実行して、East クラスターの
ocコマンドコンテキストを含む環境変数を設定します。$ export CTX_CLUSTER1=$(oc config current-context)次のコマンドを実行して、
istio-systemというプロジェクトを作成します。$ oc get project istio-system --context "${CTX_CLUSTER1}" || oc new-project istio-system --context "${CTX_CLUSTER1}"次のコマンドを実行して、East クラスターの Pod のデフォルトネットワークとして
network1を使用するように Istio を設定します。$ oc --context "${CTX_CLUSTER1}" label namespace istio-system topology.istio.io/network=network1次のコマンドを実行して、East クラスター上の Istio の CA 証明書、証明書チェーン、および秘密鍵を作成します。
$ oc get secret -n istio-system --context "${CTX_CLUSTER1}" cacerts || oc create secret generic cacerts -n istio-system --context "${CTX_CLUSTER1}" \ --from-file=east/ca-cert.pem \ --from-file=east/ca-key.pem \ --from-file=east/root-cert.pem \ --from-file=east/cert-chain.pem注記「マルチクラスターメッシュの証明書の作成」の手順に従った場合、証明書は
east/ディレクトリーに保存されます。証明書が別のディレクトリーに存在する場合は、それに応じて構文を変更してください。
マルチクラスタートポロジーの West クラスターに証明書を適用します。
次のコマンドを実行して、West クラスターにログインします。
$ oc login -u https://<west_cluster_api_server_url>次のコマンドを実行して、West クラスターの
ocコマンドコンテキストを含む環境変数を設定します。$ export CTX_CLUSTER2=$(oc config current-context)次のコマンドを実行して、
istio-systemというプロジェクトを作成します。$ oc get project istio-system --context "${CTX_CLUSTER2}" || oc new-project istio-system --context "${CTX_CLUSTER2}"次のコマンドを実行して、West クラスター上の Pod のデフォルトネットワークとして
network2を使用するように Istio を設定します。$ oc --context "${CTX_CLUSTER2}" label namespace istio-system topology.istio.io/network=network2次のコマンドを実行して、West クラスター上の Istio の CA 証明書シークレットを作成します。
$ oc get secret -n istio-system --context "${CTX_CLUSTER2}" cacerts || oc create secret generic cacerts -n istio-system --context "${CTX_CLUSTER2}" \ --from-file=west/ca-cert.pem \ --from-file=west/ca-key.pem \ --from-file=west/root-cert.pem \ --from-file=west/cert-chain.pem注記「マルチクラスターメッシュの証明書の作成」の手順に従った場合、証明書は
west/ディレクトリーに保存されます。証明書が別のディレクトリーに存在する場合は、それに応じて構文を変更します。
次のステップ
メッシュトポロジーを構成するすべてのクラスターに Istio をインストールします。