Docs 菜单
Docs 主页
/ /
MongoDB Atlas Kubernetes Operator
/

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

在此页面上

  • 受影响的配置
  • 特定于资源的注意事项
  • 迁移过程

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

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

以下配置会受到影响:

Parameter
CRD

spec.customRoles

spec.networkPeers.containerId

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

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

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

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

  • atlasProject CRD 的 spec.networkPeers 参数包含对等连接本身和支持该连接的容器的详细信息。当您从此参数迁移到 atlasNetworkPeering CRD 时,您可能需要为支持它的容器创建 atlasNetworkContainer CRD。要学习;了解更多信息,请参阅 网络容器。

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

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

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

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

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

要从参数级资源管理迁移到 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。

后退

独立的自定义资源定义