The MongoDBCommunity custom resource lets you deploy and manage MongoDB Community Edition replica sets in Kubernetes. The Kubernetes Operator uses this resource to create statefulSets, services, and other Kubernetes resources required to run MongoDB Community deployments.
詳細については、 MongoDB Community 演算子のドキュメント を参照してください。
例
次の例は、 MongoDBCommunityカスタム リソースのリソース仕様を示しています。
1 apiVersion: mongodbcommunity.mongodb.com/v1 2 kind: MongoDBCommunity 3 metadata: 4 name: my-mongodb-community 5 spec: 6 version: "8.0.0" 7 type: ReplicaSet 8 members: 3 9 security: 10 tls: 11 enabled: true 12 certificateKeySecretRef: 13 name: mongodb-tls-cert 14 caConfigMapRef: 15 name: mongodb-ca 16 authentication: 17 ignoreUnknownUsers: true 18 modes: 19 - SCRAM 20 agent: 21 logLevel: DEBUG 22 statefulSet: 23 spec: 24 template: 25 spec: 26 containers: 27 - name: mongod 28 resources: 29 limits: 30 cpu: "2" 31 memory: 2Gi 32 requests: 33 cpu: "1" 34 memory: 1Gi 35 - name: mongodb-agent 36 resources: 37 limits: 38 cpu: "1" 39 memory: 2Gi 40 requests: 41 cpu: "0.5" 42 memory: 1Gi 43 users: 44 - name: mdb-admin 45 db: admin 46 passwordSecretRef: 47 name: mdb-admin-user-password 48 scramCredentialsSecretName: mdb-admin-user 49 roles: 50 - name: root 51 db: admin
必要なMongoDBCommunity リソース設定
このセクションでは、すべてのMongoDBCommunityリソースに使用する必要がある設定について説明します。
apiVersion型: string
MongoDB Kubernetesリソーススキーマのバージョン。値を
mongodbcommunity.mongodb.com/v1に設定します。
kind型: string
作成する MongoDB Kubernetes リソースの種類。 これを
MongoDBCommunityに設定します。
metadata.name型: string
人間が判読できる名前なので、この特定の
MongoDBCommunityリソースを識別できます。リソース名は 44 文字以下にする必要があります。
spec.version型: string
配置するMongoDB Community のバージン。例:
"8.0.0"
spec.type型: string
作成する MongoDB 配置のタイプ。受け入れられる値は
ReplicaSetです。
spec.membersタイプ: 整数
Number of replica set members. This determines how many
mongodpods the Kubernetes Operator creates in the StatefulSet.
任意のMongoDBCommunity リソース設定
MongoDBCommunityカスタム リソースは、次の設定を使用できます。
セキュリティ設定
spec.security型: オブジェクト
MongoDBCommunityリソースのセキュリティ構成。TLS と認証設定が含まれています。
spec.security.tls型: オブジェクト
TLS settings for the MongoDB deployment.
spec.security.tls.enabledタイプ: ブール値
MongoDB 配置の TLS を有効または無効にするためのフラグ。TLS 暗号化された接続を有効にするには
trueに設定します。
spec.security.tls.certificateKeySecretRef.name型: string
spec.security.tls.caConfigMapRef.name型: string
Name of the Kubernetes ConfigMap that contains the Certificate Authority (CA) certificate used to verify TLS connections.
spec.security.authentication型: オブジェクト
MongoDB 配置の認証構成。
spec.security.authentication.modesタイプ: 文字列の配列
MongoDB 配置で有効にする認証メカニズムの一覧。受け入れ可能な値は以下の通りです。
SCRAM
spec.security.authentication.ignoreUnknownUsersタイプ: ブール値
trueの場合、Kubernetes 演算子 は、MongoDB の配置に存在するがMongoDBCommunityリソース仕様で定義されていないユーザーのエラーを報告しません。デフォルト:
false。
エージェント設定
spec.agent型: オブジェクト
MongoDB Agent の設定。
spec.agent.logLevel型: string
MongoDB Agent ログの冗長レベル。受け入れ可能な値は以下の通りです。
DEBUGINFOWARNERROR
StateftSet 設定
spec.statefulSet型: オブジェクト
リソース用にKubernetes Operator によって作成された
MongoDBCommunityAtlas App Services の仕様。これを使用して、デフォルトのコンテナリソースのリクエストと制限を上書きします。
spec.statefulSet.spec型: オブジェクト
Kubernetes Operator が生成されたデフォルトとマージするステートフルセット仕様。標準のKubernetes StateftSet 仕様 に従います。
spec.statefulSet.spec.template.spec.containersタイプ: オブジェクトの配列
コンテナの上書きのリスト。次のコンテナのリソースリクエストと制限を上書きできます。
mongod— MongoDB データベース コンテナ。mongodb-agent— MongoDB Agent サイドカー コンテナ。
containers: - name: mongod resources: limits: cpu: "2" memory: 2Gi requests: cpu: "1" memory: 1Gi - name: mongodb-agent resources: limits: cpu: "1" memory: 2Gi requests: cpu: "0.5" memory: 1Gi
ユーザー設定
spec.usersタイプ: オブジェクトの配列
この配置で作成する MongoDB データベースユーザーのリスト。各ユーザーオブジェクトは、データベースユーザーの認証情報とロールを定義します。
spec.users[*].name型: string
MongoDB データベースユーザーのユーザー名。
spec.users[*].db型: string
ユーザーの認証データベース。デフォルトは
adminです。
spec.users[*].passwordSecretRef.name型: string
Name of the Kubernetes secret that contains the password for this database user.
spec.users[*].scramCredentialsSecretName型: string
Kubernetes Operator がこのユーザーに対して生成された SCRAM 認証情報を保存するシークレットの名前。
spec.users[*].rolesタイプ: オブジェクトの配列
List of roles to assign to this database user.
spec.users[*].roles[*].name型: string
割り当てるロールの名前。例:
root、readWrite、readAnyDatabase、searchCoordinatorなど。
spec.users[*].roles[*].db型: string
ロールが適用されるデータベース。例:
admin
MongoDBSearch との統合
You can deploy MongoDB Search and Vector Search alongside a MongoDBCommunity resource using the MongoDBSearch CRD. To enable search functionality, create a search-sync-source user with the searchCoordinator role:
users: - name: search-sync-source db: admin passwordSecretRef: name: my-resource-search-sync-source-password scramCredentialsSecretName: my-resource-search-sync-source roles: - name: searchCoordinator db: admin
注意
MongoDB 8.2 以降では、searchCoordinator は組み込みロールです。以前のバージョンの場合、Kubernetes 演算子は searchCoordinator カスタムロールを自動的に作成します。
詳細については、「MongoDB Search とベクトル検索の配置」を参照してください。