AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

MongoDB ユーザー リソースの仕様

MongoDBUserカスタム リソースを使用すると、ユーザーが MongoDB database にアクセスするために必要な認証とロールを構成できます。

次の例は、 MongoDBUserカスタム リソースのリソース仕様を示しています。

1---
2apiVersion: mongodb.com/v1
3kind: MongoDBUser
4metadata:
5 name: ldap-user-1
6spec:
7 username: "uid=mdb0,dc=example,dc=org"
8 db: "$external"
9 mongodbResourceRef:
10 name: ldap-replica-set
11 roles:
12 - db: "admin"
13 name: "clusterAdmin"
14 - db: "admin"
15 name: "readWriteAnyDatabase"
16 - db: "admin"
17 name: "dbAdminAnyDatabase"
18
19...

このセクションでは、すべてのMongoDBUserリソースに使用する必要がある設定について説明します。

apiVersion

: string

MongoDB Kubernetes リソース スキーマのバージョン。

kind

: string

作成する MongoDB Kubernetes リソースの種類。 これをMongoDBUserに設定します。

metadata.name

: string

人間が判読できる名前なので、この特定のMongoDBUserリソースを識別できます。

リソース名は 44 文字以下にする必要があります。

spec.db

: string

これらのユーザーがアクセスする MongoDB database の名前。 デフォルトはadminです。

spec.db は、ユーザーの認証データベースを設定します。 Kubernetes Operator はこのデータベースを使用してユーザーを識別します。また、生成された接続文字列に authSource パラメータを設定し、生成された接続文字列にシークレットを付けます。

接続文字列URI パスにデータベースを設定するには、spec. connectionStringDatabase を使用します。

spec.username

: string

MongoDB database またはコレクションへの認証に必要なユーザーを識別する、人間が判読可能なラベル。

MongoDBUserカスタム リソースは、次の設定を使用できます。

spec.connectionStringDatabase

: string

Kubernetes Operator がこのユーザーに対して生成する接続文字列の URI パス内のデータベースの名前。接続文字列のシークレットを読み取るクライアントは、デフォルトでこのデータベースを使用します。

spec.connectionStringDatabase changes the URI path but not authentication, which spec.db controls. For example, a user with a spec.db of admin and a spec.connectionStringDatabase of myapp authenticates against admin and uses myapp by default:

mongodb://my-user:pass@host:27017/myapp?authSource=admin

The Kubernetes Operator applies the database to both the connectionString.standard and connectionString.standardSrv keys of the connection string secret.

Leaving this setting blank results in an empty URI path. In this case, your client determines the active database-for instance, mongosh uses``test`` by default.

spec.connectionStringSecretName

: string

Operator が作成する接続 シークレットの名前。stringKubernetes

新しいMongoDBデータベースユーザーを作成すると、 Kubernetes Operator は自動的に新しいKubernetes secret を作成します。Kubernetesシークレットには、新しいデータベースユーザーに関する次の情報が含まれています。

  • username: データベースユーザーのユーザー名

  • password: データベースユーザーのパスワード

  • connectionString.standard: このデータベース ユーザーとしてデータベースに接続できる標準接続string

  • connectionString.standardSrv: このデータベースユーザーとしてデータベースに接続できるDNS シード リスト接続string

spec.mongodbResourceRef.name

: string

このユーザーが関連付けられているMongoDB リソースの名前。 たとえば、 my-resource

spec.mongodbResourceRef.namespace

: string

The namespace that contains the secret for this user. If unspecified, the Kubernetes Operator keeps connection secrets in the same namespace as the MongoDBUser custom resource.

spec.passwordSecretKeyRef.name

: string

metadata.name ユーザーのパスワードを保存するシークレットの値。 たとえば、 my-secret-name

spec.passwordSecretKeyRef.key

: string

このMongoDBデータベースユーザーのパスワードを含むシークレット内のフィールドの名前。

詳細については、Kubernetes のドキュメント を参照してください。

spec.roles.db

: string

MongoDB database on which the role can act. For example, admin.

spec.roles.name

: string

データベースユーザーに付与するロールの名前。