重要
旧版子资源自相应的 CRD发布以来已被弃用。如果您的配置当前依赖于此资源定义的子资源形式,迁移到 CRD。
The AtlasCustomRole custom resource defines a custom database role to allocate privileges to your database users.
要在给定项目中创建此自定义角色,您必须:
对于使用Atlas Kubernetes Operator管理的项目,请在 自定义资源中引用
AtlasProject自定义资源名称AtlasCustomRoleReference the project ID of your Atlas project in the
AtlasCustomRolecustom 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中的这些资源。
AtlasProject示例,如果您在Kubernetes中删除 自定义资源,默认默认, Atlas Kubernetes Operator不再自动从Atlas中删除相应的项目。这种行为更改旨在帮助防止意外删除。 要学习;了解详情,包括如何将此行为恢复为在Atlas Kubernetes Operator.2 0之前使用的默认,请参阅新默认值: Atlas Kubernetes2 Operator.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资源执行以下操作之一:
创建新的自定义数据库角色。
更新现有的自定义数据库角色。
示例
基本示例
以下示例显示了一个定义 shard-operator自定义角色的 AtlasCustomRole 自定义资源,该角色具有备份和监控my-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: 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
独立 CRD 示例
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
AtlasCustomRole 是 AtlasCustomRole API的模式
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | atlas.mongodb.com/v1 | true |
| 字符串 |
| true |
| 对象 | 有关 | true |
| 对象 |
| false |
| 对象 |
| false |
AtlasCustomRole.spec
AtlasCustomRoleSpec 定义了Atlas中 CustomRole 的目标状态。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 对象 | 角色表示Atlas中的自定义角色。 | true |
| 对象 | 包含Atlas | false |
| 对象 |
| false |
| 对象 |
| false |
AtlasCustomRole.spec。角色
角色表示Atlas中的自定义角色。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | 标识角色的人类可读标签。对于此项目中的此自定义角色,此 | true |
| []对象 | 角色授予的个人权限 | false |
| []对象 | 该自定义角色继承的内置角色列表。 | false |
AtlasCustomRole.spec。 角色.actions
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | 用于标识特权操作的可读标签。 | true |
| []对象 | 您授予操作权限的 | true |
AtlasCustomRole.spec。 角色.actions.resources
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 布尔 | 指示是否允许对 | false |
| 字符串 | 人类可读标签,用于标识您向一个 | false |
| 字符串 | 人类可读标签,用于标识您向一个 | false |
AtlasCustomRole.spec。 角色.inheritedRoles
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | 人类可读标签,用于标识某人向一个 | true |
| 字符串 | 人类可读标签,用于标识继承的角色。 | true |
AtlasCustomRole.spec.connectionSecret
包含Atlas API私钥和公钥的密钥名称。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | true |
AtlasCustomRole.spec.externalProjectRef
externalProjectRef 保存父Atlas群组 ID(group ID)。与 "projectRef"字段互斥。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 |
| true |
AtlasCustomRole.spec.projectRef
projectRef 是对父 AtlasProject资源的引用。与 "externalProjectRef"字段互斥。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | Kubernetes资源名称 | true |
| 字符串 | Kubernetes资源的命名空间 | false |
AtlasCustomRole.status
AtlasCustomRoleStatus 是 AtlasCustomRole 自定义资源的状态。不是 AtlasProject 中包含的
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| []对象 | 条件是显示Atlas自定义资源当前省/市/自治区的列表 | true |
| 整型 |
| false |
AtlasCustomRole.status.conditions
条件描述了Atlas自定义资源在某一点的省/市/自治区。
Name | 类型 | 说明 | 必需 |
|---|---|---|---|
| 字符串 | 条件的状态; True、False、未知之一。 | true |
| 字符串 | Atlas自定义资源条件的类型。 | true |
| 字符串 | 上次条件从一种状态转换为另一种状态的时间。以 | false |
| 字符串 | 提供有关转换的详细信息的 | false |
| 字符串 | 条件的最后一次转换的 | false |