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

AtlasCustomRole カスタム リソース

重要

レガシー サブリソースは、対応する CRD のリリース時点で非推奨となります。構成が現在、このリソース定義のサブリソース形式に依存している場合は、CRD に移行します。

The AtlasCustomRole custom resource defines a custom database role to allocate privileges to your database users.

特定のプロジェクト内でこのカスタムロールを作成するには、次のいずれかを行う必要があります。

  • Atlas Kubernetes Operator で管理するプロジェクトで、 カスタムリソースで カスタム AtlasProjectリソース名を参照します。AtlasCustomRole

  • Reference the project ID of your Atlas project in the AtlasCustomRole custom resource, for projects you don't manage with Atlas Kubernetes Operator

重要

カスタム リソースはデフォルトでオブジェクトを削除しなくなりました

  • Atlas Kubernetes Operator はカスタムリソース構成ファイルを使用して Atlas 構成を管理しますが、Atlas Kubernetes Operator2.0 以降、 Kubernetesで削除したカスタム リソースは Atlas で削除されなくなりました(デフォルトでは )。代わりに、Atlas Kubernetes Operator は Atlas 内のそれらのリソースの管理を停止します。 例、 Kubernetesで カスタム リソースを削除すると、デフォルトでは、Atlas Kubernetes Operator は AtlasAtlasProject から対応するプロジェクトを自動的に削除しなくなります。この動作の変更は、誤ってまたは予期せずに削除されるのを防ぐことを目的としています。 この動作を Atlas Kubernetes Operator. 以前に使用されていたデフォルトに戻す方法などの詳細については、「2 0新しいデフォルト: Atlas Kubernetes Operator. の削除保護2 0」を参照してください。

    同様に、Atlas Kubernetes Operator を使用してKubernetesの Atlasプロジェクトからチームを削除しても、Atlas Kubernetes Operator は Atlas からチームを削除しません。

  • デフォルトのAtlas 構成値が暗黙的に使用されるのを避けるために、必要な構成の詳細を明示的に定義します。 場合によっては、Atlas のデフォルトを継承すると調整ループが発生し、カスタムリソースがREADY 状態に達しなくなります。 例、含まれている例に示すように、 AtlasDeployment カスタムリソースで必要なオートスケーリング動作を明示的に定義すると、カスタムリソース内の静的インスタンスサイズが、オートスケーリングが有効になっている Atlas 配置に繰り返し適用されないことが保証されます。

    autoScaling:
    diskGB:
    enabled: true
    compute:
    enabled: true
    scaleDownEnabled: true
    minInstanceSize: M30
    maxInstanceSize: M40

Atlas Kubernetes Operator は、Atlas カスタム データベース ロールAPIリソースを使用して次のいずれかのアクションを実行します。

  • 新しいカスタムデータベースロールを作成します。

  • 既存のカスタムデータベースロールをアップデートします。

次の例では、 my-projectプロジェクト内の シャーディングされたクラスター をバックアップとモニタリングの特権を持つ shard-operatorカスタムロールを定義する AtlasCustomRole カスタムリソースが示されています。

apiVersion: atlas.mongodb.com/v1
kind: AtlasCustomRole
metadata:
name: shard-operator-role
namespace: mongodb-atlas-system
labels:
mongodb.com/atlas-reconciliation-policy: keep
spec:
projectRef:
name: my-project
namespace: my-operator-namespace
role:
name: my-role
actions:
- name: getShardMap
resources:
cluster: true
- name: shardingState
resources:
cluster: true
- name: connPoolStats
resources:
cluster: true
- name: getLog
resources:
cluster: true
inheritedRoles:
- name: operator-role-1
role: backup

The following example shows an AtlasCustomRole independent CRD that defines the same shard-operator custom role defined in the Basic Example. This custom resource definition allows you to create this role in a project you don't manage in the same instance of Atlas Kubernetes Operator with which you define this resource. To enable independent operation, you must use an externalProjectRef instead of a projectRef, and you must supply a connectionSecret directly since this resource can't inherit API credentials from its parent project.

apiVersion: atlas.mongodb.com/v1
kind: AtlasCustomRole
metadata:
name: shard-operator-role
namespace: mongodb-atlas-system
labels:
mongodb.com/atlas-reconciliation-policy: keep
spec:
externalProjectRef:
id: 671998971c8520583f24f411
connectionSecret:
name: my-atlas-key
role:
name: my-role
actions:
- name: getShardMap
resources:
cluster: true
- name: shardingState
resources:
cluster: true
- name: connPoolStats
resources:
cluster: true
- name: getLog
resources:
cluster: true
inheritedRoles:
- name: operator-role-1
role: backup

このセクションでは、使用可能なAtlasCustomRoleカスタム リソース パラメータについて説明します。

metadata.name

型: string

必須

AtlasProjectこのカスタムロールをプロジェクトに追加するために使用する名前。

metadata.namespace

型: string

任意

atlasCustomRole カスタムリソースを含める名前空間。指定されていない場合、Atlas Kubernetes Operator は kubectl によって設定された現在の名前空間を使用します。

spec.connectionSecret.name

型: string

条件付き

Atlas Kubernetes Operator が Atlas に接続するために使用する組織IDとAPIキーを含む opaque secret の名前。指定されていない場合、Atlas Kubernetes Operator は次のいずれかにフォールバックします。

  • 親 atlasProject の spec.connectionSecretRef.name パラメータ

  • デフォルトの global シークレット(親 atlasProject に対して spec.connectionSecretRef.name が未定義の場合)

このパラメータは独立した CRD に必須です。

Atlas Kubernetes Operator atlas.mongodb.com/type=credentialsは、不要な シークレット の監視を回避するために、ラベル のシークレットのみを監視します。

次の例ではシークレットにラベルを付けます。

kubectl label secret the-user-password atlas.mongodb.com/type=credentials
spec.externalProjectRef.id

型: string

条件付き

ID of the project to which the custom role belongs. You must specify the project ID of an existing Atlas Project. This parameter is required for custom roles that belong to projects managed by either:

  • Atlas Kubernetes Operator の別のインスタンス

  • Atlas Kubernetes Operator 以外のツール

Atlas Kubernetes Operator の同じインスタンスによって管理されるプロジェクトに属するカスタムロールの場合、spec.externalProjectRef.id を使用しない場合は spec.projectRef.name を使用します。

カスタムロールは1 つのプロジェクトにのみ属することができます。 複数のプロジェクトに同じカスタムロールを定義するには、プロジェクトごとにカスタムリソース定義 を作成します。

spec.projectRef.name

型: string

条件付き

カスタムロールが属するプロジェクトの名前。 既存のAtlasProject カスタム リソース を指定する必要があります。このパラメーターは、同じインスタンスAtlas Kubernetes Operator によって管理されるプロジェクトに属するカスタムロールにのみ適用されます。

プロジェクトに属するカスタムロールの場合、次のいずれかによって管理されます。

  • Atlas Kubernetes Operator の別のインスタンス

  • Atlas Kubernetes Operator 以外のツール

spec.externalProjectRef.id を使用します。

カスタムロールは1 つのプロジェクトにのみ属することができます。 複数のプロジェクトに同じカスタムロールを定義するには、プロジェクトごとにカスタムリソース定義 を作成します。

spec.projectRef.namespace

型: string

条件付き

で指定されたAtlasProject カスタム spec.projectRef.nameリソースが存在する名前空間。

プロジェクトに属するカスタムロールの場合、次のいずれかによって管理されます。

  • Atlas Kubernetes Operator の別のインスタンス

  • Atlas Kubernetes Operator 以外のツール

このパラメーターを設定しないでください。

spec.role.actions

タイプ: 配列

任意

ロールが付与する個々の特権アクションを表すオブジェクトのリスト。

spec.role.actions.name

型: string

必須

Label that identifies the privilege action. For a complete list of actions available in the Atlas Administration API, see /reference/custom-role-actions.

spec.role.actions.resources

タイプ: 配列

任意

List of objects that indicate a database and collection on which the action is granted, or indicates that the action is granted on the cluster resource.

spec.role.actions.resources.cluster

タイプ: ブール値

任意

Flag that indicates that the action is granted on the cluster resource.

注意

This parameter is mutually exclusive with the spec.role.actions.resources.collection and spec.role.actions.resources.database parameters.

spec.role.actions.resources.collection

型: string

任意

Human-readable label that identifies the collection on which the action is granted. If this value is an empty string, the action is granted on all collections within the database specified in the spec.role.actions.resources.database parameter.

注意

This parameter is mutually exclusive with the spec.role.actions.resources.cluster parameter.

spec.role.actions.resources.database

型: string

任意

アクションが付与されるデータベースを識別する、人間が判読可能なラベル。

注意

This parameter is mutually exclusive with the spec.role.actions.resources.cluster parameter.

spec.role.inheritedRoles

タイプ: 配列

任意

継承されたロールと、そのロールが付与されているデータベースを示すキーと値のペアを表すオブジェクトのリスト。

spec.role.inheritedRoles.database

型: string

任意

継承されたロールが付与されるデータベースを識別する、人間が判読可能なラベル。

注意

This value should be admin for all roles except read and readWrite.

spec.role.inheritedRoles.name

型: string

任意

Label that uniquely identifies the inherited role. You can specify another custom role or a built-in role.