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

AtlasDeployment 自定义资源

重要

迁移到 Flex 集群

  • Atlas已将所有 M2 和 M5 集群迁移到 Flex 集群。对于无服务器实例,Atlas会根据您的使用情况将实例迁移到免费集群、Flex 集群或专用集群。要查看Atlas将您的实例迁移到哪些层级,请查阅Atlas 用户界面中的所有集群页面。要学习更多信息,请参阅 Atlas 文档中的 Flex 迁移指南。

  • Replace references to spec.serverlessSpec with configuration for spec.flexSpec.

  • Atlas Kubernetes Operator rejects new AtlasDeployment custom resources that define spec.serverlessSpec. You can only use spec.serverlessSpec to manage existing Serverless instances.

重要

Atlas Kubernetes Operator 2.0 破坏性变更 (breaking change)所需的操作

  • 在 Atlas Kubernetes Operator 2.0 中,deploymentSpec 取代了advancedDeploymentSpec AtlasDeployment自定义资源中的 。您必须按如下方式更新AtlasDeployment自定义资源:

    • 如果使用advancedDeploymentSpec ,请将其重命名为deploymentSpec 。 您无需更改任何格式。

    • 如果您在Atlas Kubernetes Operator 之前使用deploymentSpec2.0 ,请重写AtlasDeployment 自定义资源以匹配 示例中使用的格式。

  • Atlas Kubernetes Operator 使用资源文件来托管 Atlas 配置。从 Atlas Kubernetes Operator 2.0 开始,您在 Kubernetes 中删除的自定义资源将不再在 Atlas 中删除。相反,Atlas Kubernetes Operator 会停止管理这些资源。例如,如果您在 Kubernetes 中删除AtlasProject自定义资源,Atlas Kubernetes Operator 将不再自动从 Atlas 中删除相应的项目,从而防止意外删除。 要了解更多信息,包括如何将此行为恢复为 Atlas Kubernetes Operator 2.0 之前使用的默认行为,请参阅新默认值:Atlas Kubernetes Operator 2.0 中的删除保护。

AtlasDeployment 自定义资源在Atlas中配置MongoDB 集群或 Flex集群。 当您创建 AtlasDeployment 自定义资源时, Atlas Kubernetes Operator会尝试在Atlas中创建或更新集群或 Flex集群。

Atlas Kubernetes Operator 根据您在AtlasDeployment自定义资源中指定的值执行以下操作之一:

注意

Don't specify values for fields under spec.serverlessSpec because Serverless instances are deprecated. Instead, specify fields under spec.flexSpec. To learn more, see Migration to Flex Clusters.

创建免费集群只需不到 15 秒。

创建或更新 Flex集群或专用集群最多可能需要 10 分钟。Atlas Kubernetes Operator监控更新进程。

您可以运行以下命令来检查状态:

kubectl get atlasdeployment -o yaml

以下示例显示了正在配置的集群的状态部分:

status:
conditions:
- lastTransitionTime: "2024-03-18T16:32:43Z"
status: "False"
type: ClusterReady
reason: ClusterCreating
message: Cluster is provisioning

当集群或无服务器实例准备就绪时,ClusterReady 状态将更改为 True。

以下示例显示了ClusterReady状态为True的AtlasDeployment资源:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
namespace: mongodb-atlas-system
spec:
projectRef:
name: my-project
deploymentSpec:
name: test-cluster
tags:
- key: "environment"
value: "production"
replicationSpecs:
- zoneName: US-Zone
numShards: 3
regionConfigs:
- regionName: CENTRAL_US
providerName: GCP
backingProviderName: GCP
priority: 7
electableSpecs:
instanceSize: M10
nodeCount: 3
status:
conditions:
- lastTransitionTime: "2024-03-18T16:32:43Z"
status: "True"
type: Ready
- lastTransitionTime: "2024-03-18T16:32:43Z"
status: "True"
type: ClusterReady
connectionStrings:
standard: mongodb://test-cluster-shard-00-00.kpc8f.mongodb.net:27017,test-cluster-shard-00-01.kpc8f.mongodb.net:27017,test-cluster-shard-00-02.kpc8f.mongodb.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-1gm1pv-shard-0
standardSrv: mongodb+srv://test-cluster.kpc8f.mongodb.net
mongoDBVersion: 6.0
mongoURIUpdated: "2024-03-12T12:21:41Z"
observedGeneration: 1
stateName: IDLE

以下示例显示了为自动伸缩多区域集群配置的AtlasDeployment自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: test-cluster-name
namespace: mongodb-atlas-system
spec:
projectRef:
name: development
deploymentSpec:
clusterType: REPLICASET
name: service-name
tags:
- key: "environment"
value: "production"
backupEnabled: true
replicationSpecs:
- numShards: 1
regionConfigs:
- regionName: EASTERN_US
providerName: GCP
autoScaling:
diskGB:
enabled: true
compute:
enabled: true
scaleDownEnabled: true
minInstanceSize: M30
maxInstanceSize: M40
analyticsSpecs:
instanceSize: M30
nodeCount: 1
electableSpecs:
instanceSize: M30
nodeCount: 3
priority: 7
readOnlySpecs:
instanceSize: M30
nodeCount: 1

以下示例显示了配置有一些附加选项的AtlasDeployment自定义资源规范。

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
spec:
projectRef:
name: my-project
deploymentSpec:
name: test-cluster
tags:
- key: "environment"
value: "production"
replicationSpecs:
- zoneName: Zone 1
regionConfigs:
- electableSpecs:
instanceSize: M10
nodeCount: 3
providerName: AWS
regionName: US_EAST_1
priority: 7
processArgs:
javascriptEnabled: false
  • 在 1 月 2026之前,为了在一段时间内保持向后兼容性, Atlas允许您通过无服务器实例和 Flex 集群 API管理迁移的集群,包括在使用Atlas Kubernetes Operator时。

  • You can create and manage Flex clusters in the same AtlasDeployment in which you created and managed Serverless instances and M2 and M5 clusters.

  • 您无法在Atlas中创建 新的 M2/M5 集群和无服务器实例。尝试这样做会创建一个 Flex集群。

  • 即使现有的无服务器实例自 2 月初 2025起已弃用,您仍可在Atlas Kubernetes Operator中使用现有的无服务器实例。

  • For your existing Serverless instances, you can choose to replace references to spec.serverlessSpec in the AtlasDeployment with the configuration for spec.flexSpec. Or, you can continue using the same spec. Managing a deployment via the spec.serverlessSpec in the AtlasDeployment Custom Resource will continue to work even once Atlas automatically migrates these existing clusters to Flex clusters in March 2025.

  • For your existing M2 and M5 clusters, you can choose to replace references to spec.deploymentSpec in the AtlasDeployment Custom Resource with the configuration for spec.flexSpec. Or, you can continue using the same spec. Managing a deployment via the spec.deploymentSpec in the AtlasDeployment Custom Resource will continue to work even after Atlas automatically migrated these existing M2 and M5 clusters to Flex clusters in May 2025.

  • 对于现有无服务器实例,如果在协调期间收到与私有端点相关的错误,则必须升级到Atlas Kubernetes Operator 2.7.1,或将 serverlessSpec 配置替换为 AtlasDeployment 自定义资源中的 flexSpec 配置。

  • 对于 M2 和 M5 集群,为避免自动迁移后可能出现的协调错误,请对 CRD 配置进行以下更改:

    Alternatively, replace references to spec.deploymentSpec in the AtlasDeployment with the configuration for spec.flexSpec.

  • 在 2026 1 月之前,您必须从Atlas Kubernetes Operator自定义资源中删除所有剩余的 M2/M5 和无服务器实例配置,因为 API 的向后兼容性将于 2026 1 月结束,届时旧 API 将被删除,并且仅 API与 Flex 集群相关的设置将保留。

  • 较新版本的Atlas Kubernetes Operator将停止支持现有的 M2/M5 集群和无服务器实例。旧版本的Atlas Kubernetes Operator将继续支持这些实例类型,直到 1 月 2026。

要学习;了解更多信息,请参阅本指南中的迁移到 Flex 集群以及Atlas文档中的 Flex 迁移指南。

以下示例显示了为 Flex集群配置的 AtlasDeployment 自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: test-cluster-name
namespace: mongodb-atlas-system
spec:
projectRef:
name: my-project
flexSpec:
name: flex-cluster
tags:
- key: "environment"
value: "production"
providerSettings:
backingProviderName: AWS
regionName: US_EAST_1

注意

Don't specify values for fields under spec.serverlessSpec because Serverless instances are deprecated. Instead, specify fields under spec.flexSpec. To learn more, see Migration to Flex Clusters.

以下示例显示了为无服务器实例配置的 AtlasDeployment 自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: test-cluster-name
namespace: mongodb-atlas-system
spec:
projectRef:
name: development
serverlessSpec:
name: serverless-instance
tags:
- key: "environment"
value: "production"
providerSettings:
providerName: AWS
regionName: US_EAST_1

Clusters can span regions and cloud service providers. To learn more, see Considerations.

注意

While the Atlas Cluster API Resource sends requests using the v1.5 Atlas API versions, the Atlas Kubernetes Operator apiVersion field uses v1. In this case, v1 refers to the version of the Kubernetes API.

以下示例显示了为多区域集群配置的AtlasDeployment自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
spec:
projectRef:
name: my-project
deploymentSpec:
clusterType: REPLICASET
name: tenantCluster
tags:
- key: "environment"
value: "production"
replicationSpecs:
- zoneName: Zone 1
regionConfigs:
priority: 7
- electableSpecs:
instanceSize: M10
nodeCount: 3
providerName: AWS
regionName: US_EAST_1

以下示例显示了配置为跨多个云服务提供商的AtlasDeployment自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
spec:
projectRef:
name: my-project
deploymentSpec:
clusterType: REPLICASET
name: tenantCluster
tags:
- key: "environment"
value: "production"
replicationSpecs:
- regionConfigs:
- electableSpecs:
instanceSize: M10
nodeCount: 3
providerName: AWS
regionName: US_EAST_1
priority: 7
- electableSpecs:
instanceSize: M10
nodeCount: 2
providerName: AZURE
regionName: US_EAST_2
priority: 6
- electableSpecs:
instanceSize: M10
nodeCount: 2
providerName: GCP
regionName: CENTRAL_US
priority: 5

以下示例显示了配置为集合 listingsAndReviews 和 grades 创建Atlas Search索引的 AtlasDeployment 自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
namespace: mongodb-atlas-system
spec:
deploymentSpec:
backupEnabled: true
clusterType: REPLICASET
name: Test-cluster-M10
replicationSpecs:
- regionConfigs:
- backingProviderName: AWS
electableSpecs:
instanceSize: M10
nodeCount: 3
priority: 7
providerName: AWS
regionName: US_EAST_1
zoneName: Zone 1
searchIndexes:
- DBName: sample_training
collectionName: grades
name: test-vector-search-index
type: vectorSearch
vectorSearch:
fields:
- numDimensions: 1000
path: student_id
similarity: euclidean
type: vector
- DBName: sample_airbnb
collectionName: listingsAndReviews
name: my-index
search:
mappings:
dynamic: true
searchConfigurationRef:
name: atlassearchindexconfig-sample
namespace: mongodb-atlas-system
type: search
terminationProtectionEnabled: false
projectRef:
name: my-project
namespace: mongodb-atlas-system

以下示例显示了配置用于创建Atlas Search节点的 AtlasDeployment 自定义资源规范:

apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: my-atlas-cluster
namespace: mongodb-atlas-system
spec:
deploymentSpec:
backupEnabled: true
clusterType: REPLICASET
name: Test-cluster-M10
replicationSpecs:
- regionConfigs:
- backingProviderName: AWS
electableSpecs:
instanceSize: M10
nodeCount: 3
priority: 7
providerName: AWS
regionName: US_EAST_1
zoneName: Zone 1
searchNodes:
- instanceSize: S20_HIGHCPU_NVME
nodeCount: 2

本部分介绍一些可用的关键AtlasDeployment自定义资源参数。

  • For a full list of available parameters for clusters, see the Atlas Clusters API.

  • 有关 Flex 集群可用参数的完整列表,请参阅Atlas Flex 集群API。

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

要自定义规范,请参阅这些描述、可用示例和API文档。

spec.backupRef

类型:对象

Optional

包含要应用的AtlasBackupSchedule自定义资源详细信息的列表。 您可以为每个集群指定一个备份安排。

spec.backupRef.name

类型:字符串

Optional

metadata.name 要应用的备份安排的AtlasBackupSchedule自定义资源中的值。您只能为每个集群指定一个备份安排,但可以为多个集群使用相同的备份安排。

如果省略此参数,Atlas 不会将备份配置应用于此集群。

spec.backupRef.namespace

类型:字符串

Optional

字符串,表示包含要应用的备份安排的AtlasBackupSchedule自定义资源的命名空间。

spec.configServerManagementMode

类型:字符串

Optional

默认值:ATLAS_MANAGED

定义用于创建或更新分片集群的服务器管理模式的配置。可能的值为:

  • ATLAS_MANAGED: Atlas可能会自动切换集群的配置服务器类型,以获得最佳性能并节省成本。

  • FIXED_TO_DEDICATED:集群始终使用专用的配置服务器。

了解详情有关MongoDB分片集群配置服务器的更多信息。

spec.connectionSecret.name

类型:字符串

可选的

不透明密钥的名称,其中包含Atlas Kubernetes Operator用于连接到Atlas 的组织ID和API密钥。如果未指定, Atlas Kubernetes Operator会回退到以下任一项:

  • 父级 atlasProject 的 spec.connectionSecretRef.name 参数

  • 默认global 密钥(如果未为父 atlasProject 定义 spec.connectionSecretRef.name

对于独立的 CRD,此参数为必填项。

spec.deploymentSpec

类型:数组

可选的

List that contains the cluster parameters from the API. For a full list of available parameters, see the Atlas Clusters API.

重要

You must specify spec.deploymentSpec or spec.flexSpec in your configuration.

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

spec.deploymentSpec.name

类型:字符串

可选的

标识集群名称的字符串。 名称只能包含字母、数字和破折号,并且在创建部署后无法修改。

spec.deploymentSpec.clusterType

类型:字符串

可选的

人类可读标签,用于标识要创建的集群类型。

什么时候应该使用这个参数?

条件
必要性

必需

您正在部署全球集群。

必需

您正在部署非全局副本集和分片集群。

Optional

Atlas 接受:

值
集群类型

副本集(Replica Set)

复制集

分片

分片集群

GeoHARDED

spec.deploymentSpec.customZoneMapping

类型:数组

必需

List that contains Global Cluster parameters that map zones to geographic regions. For a full list of available parameters, see the Atlas Global Clusters API.

spec.deploymentSpec.customZoneMapping.location

类型:字符串

必需

表示映射到全球集群中区域的位置的代码。

spec.deploymentSpec.customZoneMapping.zone

类型:字符串

必需

Human-readable label that identifies the zone in your Global Cluster.

spec.deploymentSpec.diskSizeGB

类型:数字

Optional

表示主机根卷的容量,以 GB 为单位。 增加此数字可增加容量,最大可能值为4096 (4 TB)。 您必须为此值指定一个正数。

您无法为具有本地 NVMe SSD 的集群设立此值。

注意

If you enable auto-scaling for diskGB in any region, you can't edit this option. To learn more, see spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.diskGB.enabled.

对于 AWS 和 Google Cloud,专用集群的最小磁盘大小为 10 GB。如果您用较小的磁盘大小指定此设置,则 Atlas 默认使用最小磁盘大小值。

如果数据库部署包括 Azure 节点,则此值必须对应于现有 Azure 磁盘类型 (8、16、32、64、128、256、512、1024、2048 或 4096)。

根据您选择的是默认值还是自定义值, Atlas 计算存储费的方式会有所不同。

Atlas has disk capacity limits on single replica sets, scaling up to 4 TB for higher cluster tiers. To expand the total cluster storage beyond default limits, you can enable extended storage in the Project Settings. To accommodate further scaling in the future, we recommend that you enable sharding for long-term expansion.

如果数据库部署跨越云服务提供商, 该值默认为相关提供商的最小默认值。

To learn more, see Storage Capacity.

spec.deploymentSpec.encryptionAtRestProvider

类型:字符串

Optional

托管此集群的客户密钥的云服务提供商。您必须设置此值才能为此集群启用使用客户托管密钥的静态加密,从而提供额外的加密层。要了解更多信息,请参阅使用KMS加密数据。

Atlas 接受以下值:

值
云服务提供商

AWS

Amazon Amazon Web Services

GCP

Google Cloud

AZURE

Microsoft Azure

无

无提供商;集群不使用客户托管的密钥加密数据。

spec.deploymentSpec.managedNamespaces

类型:数组

必需

List that contains information to create a managed namespace in a specified Global Cluster to create. For a full list of available parameters, see the Atlas Global Clusters API.

spec.deploymentSpec.managedNamespaces.collection

类型:字符串

必需

要在此“全局集群”中管理的集合的人类可读标签。

spec.deploymentSpec.managedNamespaces.db

类型:字符串

必需

要在此全局集群中管理的数据库的人类可读标签。

spec.deploymentSpec.managedNamespaces.isCustomShardKeyHashed

类型:布尔值

Optional

Flag that indicates whether to hash the custom shard key for the specified collection. 此参数默认为false 。

  • 设置为true可为collection启用自定义分片键。

  • Set to false to disable a custom shard key for the collection. If diabled, MongoDB uses ranged sharding.

To learn more, see Hashed Shard Keys.

spec.deploymentSpec.managedNamespaces.isCustomShardKeyUnique

类型:布尔值

Optional

指示指定collection的自定义分片键是否唯一的标志。此参数默认为false 。

  • 设置为true可为collection启用唯一的自定义分片键。

  • 设置为false可禁用collection的唯一自定义分片键。

spec.deploymentSpec.managedNamespaces.numInitialChunks

类型:整型

Optional

Minimum number of chunks to initially create when sharding an empty collection with a hashed shard key.

要学习;了解更多信息,请参阅对全局集合进行分片。

spec.deploymentSpec.managedNamespaces.presplitHashedZones

类型:布尔值

Optional

该标志指示 MongoDB Cloud 是否应为空或不存在的 collection 创建和分发初始数据块。此参数默认为false 。

  • 设置为true可让 MongoDB Cloud 为空或不存在的collection创建和分发初始数据块。

  • 设置为false可让 MongoDB Cloud 不为空或不存在的collection创建和分发初始数据块。

spec.deploymentSpec.mongoDBMajorVersion

类型:字符串

Optional

要部署的集群的版本。 Atlas 支持M10+集群的以下 MongoDB 版本:

  • 5.0

  • 6.0

  • 7.0

  • 8.0

以下条件会产生以下结果:

条件
结果

You omit this parameter and you omit the spec.deploymentSpec.versionReleaseSystem parameter.

Atlas 部署一个运行 MongoDB 7.0 的集群。

You omit this parameter and you set the spec.deploymentSpec.versionReleaseSystem parameter to LTS.

Atlas 部署一个运行 MongoDB 7.0 的集群。

Atlas deprecated M2 and M5 clusters and Serverless instances. To learn more, see Migration to Flex Clusters. Set the spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSize parameter to M0, M2, or M5.

您必须部署MongoDB 7.0 或更高版本。

您可以指定此参数。

Atlas 始终使用发布了最新稳定补丁的指定版本部署该集群。

You set the spec.deploymentSpec.versionReleaseSystem parameter to CONTINUOUS.

您必须省略此参数。

spec.deploymentSpec.pitEnabled

类型:布尔值

可选的

注意

Atlas已弃用 M2 和 M5 集群以及无服务器实例。Atlas已将所有 M2 和 M5 集群迁移到 Flex 集群。对于无服务器实例,Atlas会根据您的使用情况将实例迁移到免费集群、Flex 集群或专用集群。

为了在一段时间内保持 API 的向后兼容性, Atlas将继续允许通过相同的 API(旧 API 和新 API)托管这些迁移的集群,包括在使用Atlas Kubernetes Operator时。 API 的向后兼容性将保持到 1 月 2026,届时旧的 API 将被删除,只有与 Flex 集群相关的 API 才会保留。

对无服务器实例上的私有端点的支持已于 2025 3 月结束。您必须在 3 月 2025 之前更新 Atlas Kubernetes Operator 配置,才能删除私有端点。您必须在1月2026之前从Atlas Kubernetes Operator配置中删除所有剩余的M2、M5和无服务器实例功能。

If your workloads require Private Endpoints or Continuous Backup, switch to Atlas Dedicated Clusters. To learn more, see Migration to Flex Clusters and the Atlas Flex Migration Guide.

启用连续云备份的配置。 要启用连续云备份,必须为此设置指定true 。

spec.deploymentSpec.replicationSpecs

类型:对象数组

可选的

List that contains the configurations for your cluster regions. Use this parameter for multi-region clusters. You must set either spec.deploymentSpec.replicationSpecs.regionConfigs.regionName or spec.deploymentSpec.replicationSpecs.

什么时候应该使用这个参数?

条件
必要性
Values

您正在部署全球集群。

必需

数组中的每个对象都代表 Atlas 部署 集群节点的区域。

您正在部署非全局副本集和分片集群。

Optional

该数组中有一个对象代表 Atlas 部署集群节点的位置。

If you specify this parameter, you must also specify spec.deploymentSpec.clusterType and spec.deploymentSpec.replicationSpecs.numShards.

spec.deploymentSpec.replicationSpecs.numShards

类型:整型

可选的

正整数,指定要为分片集群部署的分片数量。

If you use the spec.deploymentSpec.replicationSpecs parameter, you must set this parameter.

Atlas 接受1至50 (含)。 默认值为1 。

警告

When you use a sharded cluster, MongoDB requires that your applications connect to a mongos instance to ensure that your applications interact with the shards and other components of the sharded cluster properly. If you migrate from a replica set to a sharded cluster, your applications must restart to enable the connection to the cluster's mongos. As a result, the Atlas Admin API prevents you from migrating a replica set directly to a sharded cluster with more than one shard. After you successfully migrate your replica set to a single shard cluster and reset your application connections, you can add additional shards to the cluster.

spec.deploymentSpec.replicationSpecs.regionConfigs

类型:数组

必需

为地区设置的节点的硬件规格。每个regionConfigs对象都描述了该地区在选举中的优先级以及 Atlas 部署到该地区的 MongoDB 节点的数量和类型。

每个regionConfigs对象必须具有analyticsSpecs对象、 electableSpecs对象或readOnlySpecs对象。

  • M0、 M2或M5集群仅需要electableSpecs 。

  • 专用集群可以指定任何这些规范,但必须在replicationSpec中至少有一个electableSpecs对象。

  • 每个硬件规格必须使用相同的instanceSize 。

spec.deploymentSpec.replicationSpecs.regionConfigs.analyticsSpecs

类型:对象

Optional

Hardware specifications for analytics nodes needed in the region. Analytics nodes handle analytic data such as reporting queries from BI Connector for Atlas. Analytics nodes are read-only and can never become the primary.

如果不指定此参数,Atlas 不会在此区域部署分析节点。

spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.diskGB.enabled

类型:布尔值

Optional

指示此数据库部署是否启用磁盘自动伸缩的标志。 此参数默认为true 。

  • 设置为true可启用磁盘自动伸缩。

  • 设置为false可禁用磁盘自动伸缩。

The maximum amount of RAM for the selected cluster tier and the oplog size can limit storage auto-scaling. To learn more, see Customize Your Storage.

spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabled

类型:布尔值

Optional

指示是否启用实例大小自动伸缩的标志。 此参数默认为false 。

spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.maxInstanceSize

类型:字符串

可选的

String that indicates the maximum instance size to which your database deployment can automatically scale (such as M40). You must specify this parameter if you set spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabled to true.

注意

在启用自动伸缩的情况下,如果您设立的最大实例大小小于数据库部署的当前实例大小,则Atlas会自动将当前实例大小扩展到您指定的最大值。

例如,如果数据库部署的当前实例大小为M40 ,而您将最大实例大小设置为M30 ,则 Atlas 会自动将当前实例大小扩展到M30 。

If Atlas changes the current instance size and you don't change the spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSize in Atlas Kubernetes Operator to match the new instance size, Atlas Kubernetes Operator displays a warning in the logs but doesn't prevent auto-scaling.

spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.minInstanceSize

类型:字符串

可选的

String that indicates the minimum instance size to which your database deployment can automatically scale (such as M10). You must specify this parameter if you set spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabled to true.

注意

如果您设立的最小实例大小大于启用自动伸缩的数据库部署的当前实例大小,Atlas会自动将当前实例大小扩展到您指定的最小值。

例如,如果数据库部署的当前实例大小为M10 ,而您将最小实例大小设置为M30 ,则 Atlas 会自动将当前实例大小扩展到M30 。

If Atlas changes the current instance size and you don't change the spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSize in Atlas Kubernetes Operator to match the new instance size, Atlas Kubernetes Operator displays a warning in the logs but doesn't prevent auto-scaling.

spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs

类型:对象

Optional

该地区可选举节点的硬件规格。 可选举节点可以成为主节点,并且可以启用本地读取。

如果不指定该选项,Atlas 不会在该区域部署可选举节点。

spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSize

类型:字符串

可选的

此区域中实例大小的硬件规格。 每个实例大小都有默认的存储和内存容量。 您选择的实例大小会应用于实例大小内的所有数据承载主机。 要了解更多信息,请参阅Amazon Web Services 、 GCP和Azure自定义存储大小。

If you deploy a sharded cluster, or global cluster, you must choose an instance size of M30 or greater.

If you change the instance size name after you deploy your cluster, Atlas changes the database deployment to the instance size you specify unless it falls outside the range you specify in spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.minInstanceSize and spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.maxInstanceSize with auto-scaling enabled. To learn more, see spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.minInstanceSize and spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.maxInstanceSize.

注意

If you have auto-scaling enabled for the compute field, you can't edit this option. To learn more, see spec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabled.

注意

您可以更改此设置,将 M0 或 Flex集群升级到 M10+集群。但是,您不能使用此设置将 M0 或 Flex集群升级到另一个免费或 Flex集群

spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.nodeCount

类型:整型

可选的

Atlas 部署到该地区的可选举节点数量。可选举节点可以成为主节点,并且可以启用本地读取。

所有replicationSpecs.regionConfigs对象的electableSpecs.nodeCount总和必须为3 、 5或7 。

You can't create electable nodes if spec.deploymentSpec.replicationSpecs.regionConfigs.priority is 0.

spec.deploymentSpec.replicationSpecs.regionConfigs.priority

类型:整型

必需

选举主节点时,优先考虑该地区。

如果您的regionConfigs只有readOnlySpecs和/或analyticsSpecs ,请将此值设置为0 。

如果您有多个regionConfigs对象(您的集群是多地区或多云),则它们的优先级必须按降序排列。最高优先级为7 。

例子

将最高优先级区域设置为7 ,将第二高优先级区域设置为6 ,将第三优先级区域设置为5 。 如果没有可选举节点,请将此值设置为0 。

如果您的地区已将electableSpecs.nodeCount设置为1或更高,则其优先级必须比replicationSpecs.regionConfigs数组中的另一地区低一级,除非是主节点。优先级最高的区域的优先级必须为7 。 可能的最低优先级是1 。

优先级7地区标识集群的首选地区。Atlas 将主节点置于“首选地区”中。优先级1到7具有排他性:您不能为每个集群的多个地区分配给定优先级。

例子

如果有三个区域,则它们的优先级将分别为7 、 6和5 。 如果您再添加两个区域来支持可选举节点,则这些区域的优先级将分别为4和3 。

spec.deploymentSpec.replicationSpecs.regionConfigs.providerName

类型:字符串

可选的

Atlas 在其上预配主机的云服务提供商。

AWS

Amazon Amazon Web Services

GCP

Google Cloud Platform

AZURE

Microsoft Azure

spec.deploymentSpec.replicationSpecs.regionConfigs.regionName

类型:字符串

可选的

MongoDB 集群的物理位置。 您选择的区域会影响客户端访问数据库的网络延迟。

有关区域名称值的完整列表,请参阅云提供商参考页面:

For multi-region clusters, see spec.deploymentSpec.replicationSpecs. You must set either spec.deploymentSpec.replicationSpecs.regionConfigs.regionName or spec.deploymentSpec.replicationSpecs.

spec.deploymentSpec.replicationSpecs.regionConfigs.readOnlySpecs

类型:对象

Optional

地区中只读节点的硬件规格。只读节点永远不能成为主节点,但可以启用本地读取。

如果不指定此参数,Atlas 不会向该区域部署只读节点。

spec.deploymentSpec.replicationSpecs.zoneName

类型:字符串

Optional

Human-readable label that identifies the zone in a Global Cluster. Provide this value only if you set spec.deploymentSpec.clusterType to GEOSHARDED.

spec.deploymentSpec.searchIndexes

类型:数组

Optional

SearchIndex 对象的数组,其中包含描述Atlas Search索引的字段。 每个SearchIndex对象都包含以下字段:

字段
类型
说明

name

字符串

标识此索引的人类可读标签。 对于部署必须是唯一的。

DBName

字符串

人类可读标签,用于标识包含具有一个或多个 Atlas Search 索引的集合的现有数据库。

重要提示:您指定的数据库必须已经存在。 如果您没有现有数据库,请创建一个。

collectionName

字符串

可读标签,用于标识包含一个或多个 Atlas Search 索引的集合。

type

字符串

索引的类型。Atlas 接受以下值:

  • search

  • vectorSearch

search

对象

如果type为search ,则必须包含此对象。 否则,省略它。

vectorSearch

对象

如果type为vectorSearch ,则必须包含此对象。 否则,省略它。

spec.deploymentSpec.searchIndexes.search

类型:对象

Optional

字段
类型
说明

synonyms

阵列

将单词映射到此索引中的同义词的规则集

mappings

对象

集合字段的索引规范

必需

searchConfigurationRef

对象

对 AtlasSearchIndexConfig 自定义资源的名称/命名空间引用,如下所述。

必需

spec.deploymentSpec.searchIndexes.search.synonyms

类型:数组

Optional

Synonym对象的数组,其中包含描述规则集的字段,这些规则集将单词映射到该索引中的同义词。 每个Synonym对象都包含以下字段:

字段
类型
说明

name

字符串

标识同义词定义的人类可读标签。 在同一索引定义中,每个名称必须是唯一的

必需

analyzer

字符串

选择应用于要搜索的同义词的特定预定义方法。 可能的值为:

  • lucene.standard

  • lucene.standard

  • lucene.simple

  • lucene.whitespace

  • lucene.keyword

  • lucene.arabic

  • lucene.armenian

  • lucene.basque

  • lucene.bengali

  • lucene.brazilian

  • lucene.bulgarian

  • lucene.catalan

  • lucene.chinese

  • lucene.cjk

  • lucene.czech

  • lucene.danish

  • lucene.dutch

  • lucene.english

  • lucene.finnish

  • lucene.french

  • lucene.galician

  • lucene.german

  • lucene.greek

  • lucene.hindi

  • lucene.hungarian

  • lucene.indonesian

  • lucene.irish

  • lucene.italian

  • lucene.japanese

  • lucene.korean

  • lucene.kuromoji

  • lucene.latvian

  • lucene.lithuanian

  • lucene.morfologik

  • lucene.nori

  • lucene.norwegian

  • lucene.persian

  • lucene.portuguese

  • lucene.romanian

  • lucene. Russian

  • lucene.smartcn

  • lucene.sorani

  • lucene.spanish

  • lucene.swedish

  • lucene.thai

  • lucene.turkish

  • lucene.ukrainian

必需

source

对象

存储一个或多个单词到一个或多个同义词的映射关系的数据集

必需

spec.deploymentSpec.searchIndexes.search.synonyms.source

类型:对象

必需

字段
类型
说明

collection

字符串

人类可读标签,用于标识存储单词及其适用同义词的 MongoDB 集合

必需

spec.deploymentSpec.searchIndexes.search.mappings

类型:对象

必需

具有集合字段索引规范的对象:

dynamic
布尔
指示索引是使用动态映射还是静态映射的标志。 如果省略 mappings.fields,则为必填项。

fields

JSON/YAML

Atlas Search 索引的一个或多个字段规范。 如果省略 mappings.dynamic 或设置为 false,则为必填项。

spec.deploymentSpec.searchIndexes.vectorSearch

类型:对象

Optional

字段
类型
说明

fields

JSON/YAML

JSON对象数组。请参阅示例 https://dochub.mongodb.org/core/avs-vector-type

必需

spec.deploymentSpec.searchNodes

类型:数组

Optional

Atlas Search节点配置的数组。 每个元素包含两个字段:

字段
类型
说明

nodeCount

整型

集群中的Atlas Search节点数。 Atlas 接受2到32 (含)的值。 默认数字为2 。

instanceSize

字符串

Atlas Search节点实例大小的硬件规格。 Atlas 接受以下任一条件:

  • S20_HIGHCPU_NVME

  • S30_HIGHCPU_NVME

  • S40_HIGHCPU_NVME

  • S50_HIGHCPU_NVME

  • S60_HIGHCPU_NVME

  • S70_HIGHCPU_NVME

  • S80_HIGHCPU_NVME

  • S30_LOWCPU_NVME

  • S40_LOWCPU_NVME

  • S50_LOWCPU_NVME

  • S60_LOWCPU_NVME

  • S80_LOWCPU_NVME

  • S90_LOWCPU_NVME

  • S100_LOWCPU_NVME

默认实例大小为S20_HIGHCPU_NVME 。

spec.deploymentSpec.tags

类型:数组

Optional

包含标签(键值对)的列表,以便更好地了解、组织和识别数据库部署。 要了解更多信息,请参阅集群上的标签。

spec.deploymentSpec.terminationProtectionEnabled

类型:布尔值

指示是为集群启用还是禁用终止保护。 如果设立为 true, Atlas不会删除集群。 如果设立为 false, Atlas将删除集群。 默认值为 false。

spec.deploymentSpec.versionReleaseSystem

类型:字符串

可选的

Atlas 用于该集群的发布节奏。 Atlas 接受:

  • CONTINUOUS:Atlas 使用最新的 MongoDB 版本创建集群。 Atlas 会自动将您的集群更新到最新的主要 MongoDB 快速版本。

  • LTS: Atlas creates your cluster using the latest patch release of the MongoDB version that you specify in the spec.deploymentSpec.mongoDBMajorVersion parameter. Atlas automatically updates your cluster to subsequent patch releases of this MongoDB version. Atlas doesn't update your cluster to newer rapid or major MongoDB releases as they become available.

    如果省略,则默认值为 LTS。

    If you set this parameter to CONTINUOUS, you must omit the spec.deploymentSpec.mongoDBMajorVersion parameter.

spec.externalProjectRef.id

类型:字符串

可选的

部署所属项目的ID 。 您必须指定现有Atlas项目的项目ID 。对于属于以下任一组织托管的项目的部署,需要此参数:

  • Atlas Kubernetes Operator的不同实例

  • Atlas Kubernetes Operator以外的工具

对于属于同一Atlas Kubernetes Operator实例托管的项目的部署,如果不使用 spec.externalProjectRef.id,请使用 spec.projectRef.name。

spec.flexSpec

类型:数组

可选的

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

List that contains the Flex cluster parameters from the API. For a full list of available parameters, see the Atlas Flex Clusters API.

重要

You must specify spec.deploymentSpec or spec.flexSpec in your configuration.

spec.flexSpec.name

类型:字符串

标识 Flex集群名称的字符串。

spec.flexSpec.tags

类型:数组

Optional

包含标签(键值对)的列表,以便更好地了解、组织和识别数据库部署。 要了解更多信息,请参阅集群上的标签。

spec.flexSpec.terminationProtectionEnabled

类型:布尔值

指示是否为 Flex集群启用或禁用了终止保护。 如果设立为 true, Atlas不会删除集群。 如果设立为 false, Atlas将删除集群。 默认值为 false。

spec.flexSpec.providerSettings.backingProviderName

类型:字符串

Flex集群的云提供商名称。 providerSettings 包括为运行MongoDB的预配主机指定设置的配置。

Atlas接受以下值之一:

  • AWS

  • AZURE

  • GCP

spec.flexSpec.providerSettings.regionName

类型:字符串

MongoDB Flex集群的物理位置。 您选择的地区可能会影响客户端访问数据库的网络延迟。

有关区域名称值的完整列表,请参阅云提供商参考页面:

spec.processArgs

类型:对象

Optional

Object that contains the additional configuration options for your cluster.

spec.processArgs.defaultReadConcern

类型:字符串

Optional

string ,表示为此集群设立的读操作从MongoDB请求的默认确认级别。

MongoDB 5.0集群默认为本地。

spec.processArgs.defaultWriteConcern

类型:字符串

Optional

String that indicates the default level of acknowledgment requested from MongoDB for write operations set for this cluster.

MongoDB versions 5.0 and later clusters default to majority.

spec.processArgs.failIndexKeyTooLong

类型:布尔值

Optional

Flag that indicates whether to fail the operation and return an error when you insert or update documents where all indexed entries exceed 1024 bytes. If you set this to false, mongod writes documents that exceed this limit, but doesn't index them.

This option corresponds to the param.failIndexKeyTooLong mongod parameter.

spec.processArgs.javascriptEnabled

类型:布尔值

Optional

指示集群是否允许执行服务器端执行 JavaScript 的操作的标志。

spec.processArgs.minimumEnabledTlsProtocol

类型:整型

Optional

字符串,表示集群接受的传入连接的最低 TLS 版本。使用 TLS 1.0 或 1.1 的集群应考虑将 TLS 1.2 设置为最低 TLS 协议版本。

要了解更多信息,请参阅Atlas 支持哪些 TLS 版本?

This option corresponds to the net.ssl.disabledProtocols mongod configuration file option.

spec.processArgs.noTableScan

类型:布尔值

Optional

该标志指示集群是否禁用执行需要集合扫描才能返回结果的查询。

This option corresponds to the notablescan mongod parameter.

spec.processArgs.oplogSizeMB

类型:整型

Optional

指示集群 oplog 存储限制的数字,以兆字节为单位。 值为null表示集群使用 Atlas 计算的默认 oplog 大小。

This option corresponds to the replication.oplogSizeMB mongod configuration file option.

spec.processArgs.sampleRefreshIntervalBIConnector

类型:整型

Optional

收集模式信息时要采样的表明每个数据库的文档数。

该参数对应于sampleSize mongsqld选项。

spec.processArgs.sampleSizeBIConnector

类型:整型

Optional

数字,表示mongsqld 进程重新采样数据以创建其关系模式的时间间隔(以秒为单位)。

This parameter corresponds to the sampleRefreshIntervalSecs mongosqld option.

spec.projectRef.name

类型:字符串

可选的

部署所属项目的名称。 您必须指定现有的AtlasProject 自定义资源。此参数仅适用于属于由同一实例Atlas Kubernetes Operator托管的项目的部署。

对于属于以下任一机构托管的项目的部署:

  • Atlas Kubernetes Operator的不同实例

  • Atlas Kubernetes Operator以外的工具

使用 spec.externalProjectRef.id 。

spec.serverlessSpec

类型:数组

可选的

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

包含来自API的无服务器实例参数的列表。有关可用参数的完整列表,请参阅Atlas Flex 集群API。

重要

您必须在配置中指定spec.deploymentSpec或spec.flexSpec 。

spec.upgradeToDedicated

类型:布尔值

Optional

标记,当设立为 true 时,触发从 Flex集群到专用集群的就地升级。

如果省略,则默认为 false。有关迁移进程的完整演练,请参阅将 Flex集群迁移到专用集群。

重要

您还必须在 spec.deploymentSpec区块中提供目标专用集群的完整配置。此操作是单向且不可逆的。

spec.serverlessSpec.privateEndpoints

类型:数组

Optional

注意

Atlas已弃用 M2 和 M5 集群以及无服务器实例。Atlas已将所有 M2 和 M5 集群迁移到 Flex 集群。对于无服务器实例,Atlas会根据您的使用情况将实例迁移到免费集群、Flex 集群或专用集群。

为了在一段时间内保持 API 的向后兼容性, Atlas将继续允许通过相同的 API(旧 API 和新 API)托管这些迁移的集群,包括在使用Atlas Kubernetes Operator时。 API 的向后兼容性将保持到 1 月 2026,届时旧的 API 将被删除,只有与 Flex 集群相关的 API 才会保留。

对无服务器实例上的私有端点的支持已于 2025 3 月结束。您必须在 3 月 2025 之前更新 Atlas Kubernetes Operator 配置,才能删除私有端点。您必须在1月2026之前从Atlas Kubernetes Operator配置中删除所有剩余的M2、M5和无服务器实例功能。

If your workloads require Private Endpoints or Continuous Backup, switch to Atlas Dedicated Clusters. To learn more, see Migration to Flex Clusters and the Atlas Flex Migration Guide.

已弃用。 删除此参数(如果存在)。 包含无服务器实例的私有端点配置的列表。

spec.serverlessSpec.providerSettings

类型:对象

可选的

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

为运行MongoDB 的预配主机指定设置的配置。 可用选项特定于云服务提供商。 要学习;了解更多信息,请参阅Amazon Web Services 、 GCP和Azure无服务器实例配置选项。

如果要创建或更新无服务器实例,必须指定此设置。

重要

以下设置已弃用,并将在未来版本中删除:

  • spec.serverlessSpec.providerSettings.DiskIOPS

  • spec.serverlessSpec.providerSettings.DiskTypeName

  • spec.serverlessSpec.providerSettings.EncryptEBSVolume

  • spec.serverlessSpec.providerSettings.InstanceSizeName

  • spec.serverlessSpec.providerSettings.VolumeType

  • spec.serverlessSpec.providerSettings.AutoScaling

为其中任何设置提供值都不起作用。

spec.serverlessSpec.providerSettings.providerName

类型:字符串

可选的

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

Atlas为无服务器实例预配托管的云服务提供商。

Atlas 接受以下值:

AWS

Amazon Amazon Web Services

GCP

Google Cloud Platform

AZURE

Microsoft Azure

spec.serverlessSpec.providerSettings.regionName

类型:字符串

可选的

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

MongoDB 无服务器实例的物理位置。 您选择的区域会影响客户端访问数据库的网络延迟。

有关区域名称值的完整列表,请参阅云提供商参考页面:

spec.serverlessSpec.tags

注意

有关更改的完整信息,请参阅过渡到 Flex 集群的说明。

类型:数组

Optional

包含标签(键值对)的列表,以便更好地了解、组织和识别数据库部署。 要了解更多信息,请参阅集群上的标签。

status.connectionStrings

类型:数组

必需

列表,其中包含用于访问集群的连接 URL。 该参数会在创建或更新集群后出现。

注意

.. include:: /includes/fact-ak8so-connection-strings.rst

有关可通过 API 获取的集群配置参数,请参阅“Atlas 集群 API”。

注意

以下参数在 Atlas API 中已弃用,Atlas Kubernetes Operator 不支持这些参数:

  • replicationSpec

  • replicationFactor