The MongoDB Controllers for Kubernetes Operator uses a Kubernetes ConfigMap to link to a single and unique Ops Manager Project. If the referenced project doesn't exist, the Kubernetes Operator creates it according to the projectName that you provide in the ConfigMap.
Kubernetes Operator ConfigMap を作成するには、例ConfigMap YAMLファイルの数行を編集し、ConfigMap を適用します。完全な例を表示するには、プロジェクトの.YAMLファイルを参照してください。
あるいは、 MongoDB Cloud Manager UIまたはMongoDB Ops Manager UIを使用してプロジェクトを作成または選択し、ConfigMap YAML ファイルを自動的に生成し、 Kubernetes環境に適用できるようにすることもできます。
Considerations
配置できる MongoDB リソースはプロジェクトごとに 1 つだけです。 この制限が適用されるのは、MongoDB Ops Manager がプロジェクトごとのデータベースユーザーのアクセスに対して 1 つの認証方法のみをサポートしているためです。 詳細については、「 MongoDB Database リソースの配置 」を参照してください。
You must pair a MongoDB Controllers for Kubernetes Operator deployment to a unique Ops Manager Project. You can either create a distinct ConfigMap for each MongoDB Controllers for Kubernetes Operator instance you deploy, or you can reuse the same ConfigMap for any number of deployments by omitting the
data.projectNamefrom your ConfigMap, so that project names align with deployed resource names. Where a project name is provided in the config map, if that project does not exist yet it will be created.
重要
Kubernetes演算子を使用して、MongoDB Cloud ManagerMongoDB Ops Managerおよび バージョン6.0 .x 以降で リソースを配置できます。
Atlas 演算子を使用して、MongoDB リソースを Atlas に配置できます。
前提条件
Kubernetesバージョン 1.11 以降、またはOpenShiftバージョン 3.11 以降。
Kubernetes Operator 用のMongoDBドライバー
コンフィギュレーションマップを使用して 1 つのプロジェクトを作成
kubectlをデフォルトで名前空間に設定します。
まだ作成していない場合は、次のコマンドを実行して、作成した名前空間ですべてのkubectlコマンドを実行します。
注意
MongoDB Ops Manager リソースを複数の Kubernetes クラスター MongoDB 配置に配置している場合、次の手順に従います。
contextを演算子クラスターの名前に設定します(kubectl config set context "$MDB_CENTRAL_CLUSTER_FULL_NAME"など)。MongoDB のマルチ配置に使用したのと同じスコープ(例:
kubectl config --namespace "mongodb"に--namespaceを設定します。
kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
以下のコマンドを呼び出して ConfigMap を作成します。
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: ConfigMap metadata: name: my-project namespace: mongodb data: projectName: myProjectName # this is an optional parameter; when omitted, the Operator creates a project with the resource name orgId: 5b890e0feacf0b76ff3e7183 # this is a required parameter baseUrl: https://ops.example.com:8443 EOF
キー | タイプ | 説明 | 例 |
|---|---|---|---|
| string |
| |
| string |
| |
| string | Label for your Ops Manager Project. The Kubernetes Operator creates the Ops Manager project if it does not exist. If you omit the Cloud ManagerまたはMongoDB Ops Manager組織で既存のプロジェクトを使用するには、 Cloud ManagerまたはMongoDB Ops Managerページの左上にある All Clusters リンクをクリックし、Search で名前を検索して、 |
|
| string | 必須。 または 組織 を一意に識別する24 文字の 16stringCloud Manager MongoDB Ops Manager進 。 Kubernetes演算子を使用して、MongoDB Cloud ManagerMongoDB Ops Managerおよび バージョン6.0 .x 以降で リソースを配置できます。 Atlas 演算子を使用して、MongoDB リソースを Atlas に配置できます。 Specify an existing Organization:
既存の Cloud Managerまたは 組織内に新しいプロジェクトを作成するには、 組織プロジェクト作成者MongoDB Ops Manager ロールが必要です。
|
|
| string | FQDN とポート番号を含む MongoDB Ops Manager アプリケーションへの URL 。 重要: を Operator で配置し、 MongoDB Ops Managerが配置先のKubernetes クラスターのMongoDB Ops Manager MongoDB外部 に配置された データベースリソースを管理する場合、Kubernetes Cloud Manager を使用している場合は、 |
|
次のKubernetesコマンドを呼び出して、ConfigMapを確認します。
kubectl describe configmaps <configmap-name>
このコマンドは、shell に ConfigMap の説明を返します。
Name: <configmap-name> Namespace: <namespace> Labels: <none> Annotations: <none> Data ==== baseUrl: ---- <myOpsManagerURL> Events: <none>
カスタム CA を使用した HTTPS 対応のMongoDB Ops Managerへの接続
MongoDB Ops Manager インスタンスで HTTPS を有効にするために、独自の TLS 証明書を使用することを選択した場合があります。カスタム証明書を使用した場合は、そのカスタム証明書に署名した CA を Kubernetes Operator に追加する必要があります。 カスタム CA を追加するには、次の手順を実行します。
証明機関(CA)証明書の ConfigMap を作成します。
The Kubernetes Operator requires the root CA certificate of the CA that issued the Ops Manager host's certificate. Run the following command to create a ConfigMap containing the root CA in the same namespace of your database Pods:
kubectl -n <metadata.namespace> create configmap <root-ca-configmap-name> \ --from-file=mms-ca.crt
重要
Kubernetes Operator では、ConfigMap でMongoDB Ops Managerリソースの証明書 mms-ca.crt に名前を付ける必要があります。
次の例ConfigMap の強調表示されたセクションをコピーします。
1 2 apiVersion: v1 3 kind: ConfigMap 4 metadata: 5 name: <my-configmap> 6 namespace: <my-namespace> 7 data: 8 projectName: <my-ops-manager-project-name> # this is an optional parameter 9 orgId: <org-id> # this is a required parameter 10 baseUrl: https://<my-ops-manager-URL>
11 sslMMSCAConfigMap: <root-ca-configmap-name> 12 sslRequireValidMMSServerCertificates: ‘true’ 13 ...
強調表示されたセクションをプロジェクトの ConfigMap に追加します。
次のコマンドを呼び出して、デフォルトの構成済みエディターでプロジェクトの ConfigMap を編集します。
kubectl edit configmaps <my-configmap> -n <metadata.namespace> 強調表示されたセクションを例の ConfigMap に貼り付けます プロジェクト ConfigMap の最後にある。
TLS 設定の指定
次のTLSキーを変更します。
キー | タイプ | 説明 | 例 |
|---|---|---|---|
| string | Name of the ConfigMap created in the first step containing the root CA certificate used to sign the Ops Manager host's certificate. This mounts the CA certificate to the Kubernetes Operator and database resources. |
|
| ブール値 | からの有効な TLS MongoDB Ops Manager証明書を要求するように演算子を強制します。 重要:値は一重引用符で囲む必要があります。そうしないと、 演算子はエラーをスローします。 |
|
Kubernetesコマンドを呼び出してConfigMapを確認します。
kubectl describe configmaps <my-configmap> -n <metadata.namespace>
重要
Always include the namespace option with kubectl. kubectl defaults to an empty namespace if you don't specify the -n option, resulting in deployment failures. You must specify the value of the <metadata.namespace> field. The Kubernetes Operator, secret, and MongoDB resources should run in the same unique namespace.
このコマンドは、shell に ConfigMap の説明を返します。
Name: <my-configmap> Namespace: <namespace> Labels: <none> Annotations: <none> Data ==== sslMMSCAConfigMap: ---- <root-ca-configmap-name> sslRequireValidMMSServerCertificates: ---- true Events: <none>
次のステップ
ConfigMap が作成されたので、 MongoDB リソースの配置 を開始する前 に、 Kubernetes Operator の認証情報を作成 します 。