Atlas Kubernetes Operator支持从 Flex集群就地迁移到 Dedicated集群。这使您能够直接在Kubernetes环境中扩展数据库基础架构。
先决条件
在开始之前,您必须具备以下条件:
由Atlas Kubernetes Operator托管的现有 Flex 集群层
AtlasDeployment
。修改Kubernetes集群中 Flex 集群层
AtlasDeployment
资源的权限。为您的Atlas项目启用计费功能。升级将导致向您的Atlas账户收取费用。
步骤
查找要升级的Flex集群配置。
您可以在Atlas Kubernetes Operator托管的AtlasDeployment
资源中找到您的 Flex集群配置。
以下示例显示了 us-east-1
地区中Amazon Web Services上的 Flex集群配置。
# my-cluster.yaml apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-flex-cluster spec: projectRef: name: my-atlas-project flexSpec: name: my-cluster providerSettings: backingProviderName: AWS regionName: US_EAST_1
添加spec.upgradeToDedicated
字段和目标专用集群的完整配置。
将 spec.upgradeToDedicated
字段添加到 AtlasDeployment
资源中。此字段是一个布尔标志,当设立为 true
时,将启动从 Flex集群到专用集群的就地升级。
在 spec.deploymentSpec
区块中,提供目标专用集群的完整配置。其中包括提供商、 地区、实例大小和任何其他必要参数等详细信息。
为专用集群使用与原始 Flex集群相同的名称。
注意
如果您为专用集群使用不同的名称,迁移将失败。
以下示例展示了如何修改 Flex集群配置以启动到专用集群的迁移。
# my-cluster.yaml apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: # The name MUST remain the same name: my-flex-cluster spec: projectRef: name: my-atlas-project # Add the upgrade flag upgradeToDedicated: true # Add the full configuration for the target Dedicated-cluster deploymentSpec: name: "my-cluster" # The name MUST remain the same clusterType: REPLICASET backupEnabled: true replicationSpecs: - regionConfigs: - providerName: AWS regionName: US_EAST_1 priority: 7 electableSpecs: instanceSize: M10 nodeCount: 3
监控迁移进程。
Atlas Kubernetes Operator会立即启动迁移进程。您可以使用 kubectl describe
命令监控进度。
kubectl describe atlasdeployment my-flex-cluster
最初,DeploymentReady
条件显示如下:
Status: Conditions: ... - Last Transition Time: 2025-06-18T10:00:00Z Message: Cluster upgrade to dedicated instance initiated in Atlas... Reason: FlexToDedicatedMigrationProgressing Status: "False" Type: DeploymentReady
迁移完成后,DeploymentReady
条件将更新为:
Status: Conditions: ... - Last Transition Time: 2025-06-18T10:15:00Z Message: Cluster upgrade successful. You can now remove the 'upgradeToDedicated' flag from the spec. Status: "True" Type: DeploymentReady
升级完成后,您还会在输出中看到一个 Normal
事件。如果迁移失败,DeploymentReady
条件会显示错误消息,Reason
条件则会显示错误消息。如果您已将集群迁移到 专用集群,则不会有任何变化。
迁移后清理。
迁移完成后,您可以从 AtlasDeployment
资源中删除upgradeToDedicated
标志,然后再次应用。此步骤是可选步骤,但建议执行此步骤,以保持配置简洁并防止意外重新触发迁移。
最终的 AtlasDeployment
资源如以下示例所示:
# my-cluster.yaml apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: name: my-flex-cluster spec: projectRef: name: my-atlas-project deploymentSpec: name: "my-cluster" # The name MUST remain the same clusterType: REPLICASET backupEnabled: true replicationSpecs: - regionConfigs: - providerName: AWS regionName: US_EAST_1 priority: 7 electableSpecs: instanceSize: M10 nodeCount: 3