この手順を使用して、マルチ Kubernetes クラスター MongoDB 配置のノード Kubernetes クラスターに新しいレプリカセットを作成します。
この手順により、ステートメントセット構成のオーバーライドなど、レプリカセット リソースのさまざまな設定を設定できます。 この手順を使用する代わりに、マルチKubernetes-クラスター クイック スタート を使用できます。これにより、デフォルト設定でマルチ Kubernetes クラスター MongoDB 配置が作成されます。
始める前に:
Kubernetes 演算子 をマルチ Kubernetes クラスター MongoDB 配置にインストールします。 「マルチ Kubernetes クラスター クイック スタート 」を参照してください。
リソースの配置MongoDBMultiCluster
このTLS-Encrypted Connectionsタブでは、次の手順を使用できます。
MongoDBMultiClusterリソースを配置MongoDBMultiClusterリソースの TLS 証明書を更新する
これらの手順では、レプリカセット内の MongoDB ホスト間、およびクライアント アプリケーションと MongoDB 配置間で、 TLSで暗号化された接続を確立します。
開始する前に、 TLS暗号化の有効な証明書が必要です。
リソースの配置MongoDBMultiCluster
リソースの TLSMongoDBMultiCluster 証明書のシークレットを作成します。
kubectlコマンドを実行して、 MongoDBMultiClusterリソース証明書を保存する新しいシークレットを作成します。
kubectl --context $MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace=<metadata.namespace> \ create secret tls <prefix>-<metadata.name>-cert \ --cert=<resource-tls-cert> \ --key=<resource-tls-key>
注意
シークレットの前に<prefix>-<metadata.name>を付ける必要があります。
For example, if you call your deployment my-deployment and you set the prefix to mdb, you must name the TLS secret for the client TLS communications mdb-my-deployment-cert. Also, you must name the TLS secret for internal cluster authentication (if enabled) mdb-my-deployment-clusterfile.
ConfigMap を作成して、CA を MongoDBMultiClusterリソースにリンクします。
Run the kubectl command to link your CA to your MongoDBMultiCluster resource. Specify the CA certificate file that you must always name ca-pem for the MongoDBMultiCluster resource:
kubectl --context $MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace=<metadata.namespace> \ create configmap custom-ca -from-file=ca-pem=<your-custom-ca-file>
サンプル リソースをコピーして貼り付けます。
サンプル レプリカセットのYAMLファイルをコピーし、新しいテキストファイルに貼り付けます。
必要なレプリカセット構成に合わせてファイルの設定を変更します。
1 # This example provides statefulSet overrides per cluster. 2 3 apiVersion: mongodb.com/v1 4 kind: MongoDBMultiCluster 5 metadata: 6 name: multi-replica-set 7 spec: 8 version: 8.0.0 9 type: ReplicaSet 10 duplicateServiceObjects: false 11 credentials: my-credentials 12 opsManager: 13 configMapRef: 14 name: my-project 15 clusterSpecList: 16 - clusterName: cluster1.example.com 17 members: 2 18 statefulSet: 19 spec: 20 template: 21 spec: 22 containers: 23 # Example of custom sidecar containers. Remove it before using the file in production. 24 - name: sidecar1 25 image: busybox 26 command: [ "sleep" ] 27 args: [ "infinity" ] 28 # Use the following settings to override the default storage size of the "data" Persistent Volume. 29 volumeClaimTemplates: 30 - metadata: 31 name: data 32 spec: 33 resources: 34 requests: 35 storage: 1Gi 36 - clusterName: cluster2.example.com 37 members: 1 38 statefulSet: 39 spec: 40 template: 41 spec: 42 containers: 43 # Example of custom sidecar containers. Remove it before using the file in production. 44 - name: sidecar2 45 image: busybox 46 command: [ "sleep" ] 47 args: [ "infinity" ] 48 volumeClaimTemplates: 49 - metadata: 50 name: data 51 spec: 52 resources: 53 requests: 54 storage: 1Gi 55 - clusterName: cluster3.example.com 56 members: 1 57 statefulSet: 58 spec: 59 template: 60 spec: 61 containers: 62 # Example of custom sidecar containers. Remove it before using the file in production. 63 - name: sidecar3 64 image: busybox 65 command: [ "sleep" ] 66 args: [ "infinity" ] 67 volumeClaimTemplates: 68 - metadata: 69 name: data 70 spec: 71 resources: 72 requests: 73 storage: 1Gi 74 75 ...
設定を希望する値に変更します。
キー | タイプ | 説明 | 例 |
|---|---|---|---|
string |
リソース名は 44 文字以下にする必要があります。
|
| |
string | この 形式は、 MongoDB Community Editionでは 重要:互換性のあるMongoDB Serverバージョンを選択していることを確認してください。 互換性のあるバージョンは、 MongoDBデータベースリソースが使用する基本イメージによって異なります。 MongoDB のバージョン管理の詳細については、MongoDB マニュアルの「 MongoDBのバージョン管理 」を参照してください。 |
| |
| string | Name of the ConfigMap with the Ops Manager connection configuration. The この値は、作成するリソースと同じ名前空間に存在する必要があります。 重要: Kubernetes Operator は ConfigMap への変更を追跡し、 |
|
| string |
|
|
| integer | このクラスター内のメンバーの数。 |
|
| コレクション | 任意。 マルチ Kubernetes クラスターMongoDBデプロイ内のクラスターの各ステートメントに対して、StatusSet オーバーライドの構成を提供します。 の下で個々のクラスター | 例 を参照してください。 |
| コレクション | 任意。 指定すると、 VolumeClaim テンプレート のデフォルトのストレージ サイズのクラスターごとの上書きが行われます。 、データを保存する永続ボリュームの場合 | 例 を参照してください。 |
string | Name of the secret you created as Ops Manager API authentication credentials for the Kubernetes Operator to communicate with Ops Manager. 認証情報を保持するMongoDB Ops Manager Kubernetes Secretオブジェクトは、作成するリソースと同じ名前空間に存在する必要があります。 重要: Kubernetes Operator は、シークレットへの変更を追跡し、 |
| |
string | 作成する |
|
MongoDBMultiClusterリソース配置に追加で許容される設定を追加します。
また、オブジェクト仕様に任意の設定を追加することもできます。「 マルチ Kubernetes クラスター リソース仕様 」を参照してください。
Save this replica set config file with a .yaml extension.
Start your replica set deployment.
任意のディレクトリで、次の Kubernetes コマンドを呼び出してレプリカセットを作成します。
kubectl apply -f <replica-set-conf>.yaml
マルチ Kubernetes クラスター MongoDB 配置のステータスを追跡します。
MongoDBMultiClusterリソースのステータスを確認するには、 演算子クラスターで次のコマンドを使用します。
kubectl get mdbmc <resource-name> -o yaml -w
-w (監視)フラグが設定されている場合、構成が変更されると、ステータスフェーズがRunning状態に達するまで出力が直ちに更新されます。 リソース配置ステータスの詳細については、 「 Kubernetes 演算子のトラブルシューティング 」を参照してください。
MongoDBMultiCluster リソースの TLS 証明書を更新する
次の手順で、 TLS証明書を定期的に更新します。
Renew the secret for a MongoDBMultiCluster resource.
次のkubectl コマンドを実行して、MongoDBMultiCluster リソースの証明書を保存する既存のシークレットを更新します。
kubectl --context $MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace=<metadata.namespace> \ create secret tls <prefix>-<metadata.name>-cert \ --cert=<resource-tls-cert> \ --key=<resource-tls-key> \ --dry-run=client \ -o yaml | kubectl apply -f -
この手順では、レプリカセット内の MongoDB ホスト間、およびクライアント・アプリケーションと MongoDB 配置間の接続は暗号化されません。
リソースの配置MongoDBMultiCluster
サンプル リソースをコピーして貼り付けます。
サンプル レプリカセットのYAMLファイルをコピーし、新しいテキストファイルに貼り付けます。
必要なレプリカセット構成に合わせてファイルの設定を変更します。
1 # This example provides statefulSet overrides per cluster. 2 3 apiVersion: mongodb.com/v1 4 kind: MongoDBMultiCluster 5 metadata: 6 name: multi-replica-set 7 spec: 8 version: 8.0.0 9 type: ReplicaSet 10 duplicateServiceObjects: false 11 credentials: my-credentials 12 opsManager: 13 configMapRef: 14 name: my-project 15 clusterSpecList: 16 - clusterName: cluster1.example.com 17 members: 2 18 statefulSet: 19 spec: 20 template: 21 spec: 22 containers: 23 # Example of custom sidecar containers. Remove it before using the file in production. 24 - name: sidecar1 25 image: busybox 26 command: [ "sleep" ] 27 args: [ "infinity" ] 28 # Use the following settings to override the default storage size of the "data" Persistent Volume. 29 volumeClaimTemplates: 30 - metadata: 31 name: data 32 spec: 33 resources: 34 requests: 35 storage: 1Gi 36 - clusterName: cluster2.example.com 37 members: 1 38 statefulSet: 39 spec: 40 template: 41 spec: 42 containers: 43 # Example of custom sidecar containers. Remove it before using the file in production. 44 - name: sidecar2 45 image: busybox 46 command: [ "sleep" ] 47 args: [ "infinity" ] 48 volumeClaimTemplates: 49 - metadata: 50 name: data 51 spec: 52 resources: 53 requests: 54 storage: 1Gi 55 - clusterName: cluster3.example.com 56 members: 1 57 statefulSet: 58 spec: 59 template: 60 spec: 61 containers: 62 # Example of custom sidecar containers. Remove it before using the file in production. 63 - name: sidecar3 64 image: busybox 65 command: [ "sleep" ] 66 args: [ "infinity" ] 67 volumeClaimTemplates: 68 - metadata: 69 name: data 70 spec: 71 resources: 72 requests: 73 storage: 1Gi 74 75 ...
設定を希望する値に変更します。
キー | タイプ | 説明 | 例 |
|---|---|---|---|
string |
リソース名は 44 文字以下にする必要があります。
|
| |
string | この 形式は、 MongoDB Community Editionでは 重要:互換性のあるMongoDB Serverバージョンを選択していることを確認してください。 互換性のあるバージョンは、 MongoDBデータベースリソースが使用する基本イメージによって異なります。 MongoDB のバージョン管理の詳細については、MongoDB マニュアルの「 MongoDBのバージョン管理 」を参照してください。 |
| |
| string | Name of the ConfigMap with the Ops Manager connection configuration. The この値は、作成するリソースと同じ名前空間に存在する必要があります。 重要: Kubernetes Operator は ConfigMap への変更を追跡し、 |
|
| string |
|
|
| integer | このクラスター内のメンバーの数。 |
|
| コレクション | 任意。 Provides the configuration for the StatefulSet override for each of the cluster's StatefulSets in a multi-Kubernetes cluster MongoDB deployment. If specified at an individual cluster level under | 例 を参照してください。 |
| コレクション | 任意。 指定すると、 VolumeClaim テンプレート のデフォルトのストレージ サイズのクラスターごとの上書きが行われます。 、データを保存する永続ボリュームの場合 | 例 を参照してください。 |
string | Name of the secret you created as Ops Manager API authentication credentials for the Kubernetes Operator to communicate with Ops Manager. 認証情報を保持するMongoDB Ops Manager Kubernetes Secretオブジェクトは、作成するリソースと同じ名前空間に存在する必要があります。 重要: Kubernetes Operator は、シークレットへの変更を追跡し、 |
| |
string | 作成する |
|
MongoDBMultiClusterリソース配置に追加で許容される設定を追加します。
また、オブジェクト仕様に任意の設定を追加することもできます。「 マルチ Kubernetes クラスター リソース仕様 」を参照してください。
Save this replica set config file with a .yaml extension.
Start your replica set deployment.
任意のディレクトリで、次の Kubernetes コマンドを呼び出してレプリカセットを作成します。
kubectl apply -f <replica-set-conf>.yaml
マルチ Kubernetes クラスター MongoDB 配置のステータスを追跡します。
MongoDBMultiClusterリソースのステータスを確認するには、 演算子クラスターで次のコマンドを使用します。
kubectl get mdbmc <resource-name> -o yaml -w
-w (監視)フラグが設定されている場合、構成が変更されると、ステータスフェーズがRunning状態に達するまで出力が直ちに更新されます。 リソース配置ステータスの詳細については、 「 Kubernetes 演算子のトラブルシューティング 」を参照してください。