对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

将参数迁移到自定义资源定义

从Atlas Kubernetes Operator版本 2.6 开始,以前采用参数形式的各种资源配置已转换为自己的 CRD。 对基于参数的父资源配置的支持已弃用。 现有的基于参数的父资源配置将继续有效,但未来发布将删除对这些配置的支持。

如需将来继续通过Atlas Kubernetes Operator管理这些资源,迁移到相应的 CRD。

以下配置会受到影响:

在将参数迁移到资源之前,请考虑特定于这些参数的任何实施细节。

以下注意事项应用于 atlasNetworkPeering 资源:

  • atlasNetworkPeering CRD 可以通过Kubernetes名称引用或ID引用其相应的 atlasNetworkContainer。

  • atlasNetworkPeering CRD 可以通过Kubernetes名称引用或ID来引用托管它的 atlasProject。

  • The spec.networkPeers parameter of an atlasProject CRD contains details of both the peering connection itself and the container that supports it. When you migrate from this parameter to an atlasNetworkPeering CRD, you might need to create an atlasNetworkContainer CRD for the container that supports it. To learn more, see Network Container.

以下注意事项应用于 atlasNetworkContainer 资源:

  • 如果出现以下任一情况,则在将 atlasNetworkPeering 连接从参数迁移到资源时,无需创建新的 atlasNetworkContainer资源:

    • 您管理支持Atlas Kubernetes Operator atlasProject 之外的 atlasNetworkPeering 连接的网络容器,您可以在其中管理atlasNetworkPeering 连接

    • atlasNetworkPeering 连接容器的 atlasNetworkContainer资源已存在。

  • atlasNetworkContainer CRD 可以通过Kubernetes名称引用或ID引用其托管atlasProject。

以下注意事项应用于 AtlasThirdPartyIntegration 资源:

  • 每个第三方集成都需要自己的 AtlasThirdPartyIntegration资源。您不能在同一资源中定义多个集成。

  • 每个项目只能有特定类型第三方集成的一个实例,无论是由 AtlasProject资源中该类型的 spec.integrations 条目配置,还是由具有该值的 spec.type 的 AtlasThirdPartyIntegration资源配置。

    示例,如果您的 AtlasThirdPartyIntegration CRD 为 spec.type DATADOG,则无法在 AtlasProject资源中声明 spec.integrations.type 为 DATADOG。

要从参数级资源管理迁移到 CRD管理:

1

禁用项目协调并编辑子资源引用。

  1. 将 mongodb.com/atlas-reconciliation-policy: "skip" 注解添加到父资源的 metadata。 这可以防止Atlas Kubernetes Operator尝试协调父资源及其子资源。

  2. 为防止与您创建的新 CRD 发生冲突,您必须从父资源中删除与要迁移的资源对应的参数。

考虑以下具有 customRoles 配置的 atlasProject示例:

apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: my-project
spec:
name: Test project
connectionSecretRef:
name: my-atlas-key
customRoles:
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
projectIpAccessList:
- cidrBlock: "203.0.113.0/24"
comment: "CIDR block for Application Server B - D"

确保您已在第 5 和 6 行中添加 annotations区块,并删除上示例中所示的 customRoles区块。

apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: my-project
annotations:
mongodb.com/atlas-reconciliation-policy: "skip"
spec:
name: Test project
connectionSecretRef:
name: my-atlas-key
projectIpAccessList:
- cidrBlock: "203.0.113.0/24"
comment: "CIDR block for Application Server B - D"

警告

如果您不应用此注解, Atlas Kubernetes Operator将在您修改其他资源时继续尝试协调。 对于在Atlas Kubernetes OperatorAtlas Kubernetes Operator2.0 中禁用“新默认值:删除保护”的用户,这可能会导致Atlas KubernetesAtlas Kubernetes Operator AtlasOperator在您删除atlasProject 资源时删除Atlas项目,或者在尝试删除具有活动子资源的项目时进入阻止状态例如数据库用户或部署。

2

为防止与您创建的新 CRD 发生冲突,您必须先从父资源中删除与要迁移的资源对应的参数。 示例,从之前显示的 atlasProject CRD 中删除customRoles 参数:

apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: my-project
annotations:
mongodb.com/atlas-reconciliation-policy: "skip"
spec:
name: Test project
connectionSecretRef:
name: my-atlas-key
projectIpAccessList:
- cidrBlock: "203.0.113.0/24"
comment: "CIDR block for Application Server B - D"
3

根据要迁移的参数的语法,为该参数创建相应的 kind CRD。 示例,要迁移前面显示的customRoles atlasProjectCRD 的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
4
5

此外,您现在可以将此资源配置为独立 CRD。