迁移到 Flex 集群
重要
迁移到 Flex 集群
Replace references to
spec.serverlessSpecwith configuration forspec.flexSpec.Atlas Kubernetes Operator rejects new
AtlasDeploymentcustom resources that definespec.serverlessSpec. You can only usespec.serverlessSpecto manage existing Serverless instances.
Atlas Kubernetes Operator 2.0 的重大更改
重要
Atlas Kubernetes Operator 2.0 破坏性变更 (breaking change)所需的操作
在 Atlas Kubernetes Operator 2.0 中,
deploymentSpec取代了advancedDeploymentSpecAtlasDeployment自定义资源中的 。您必须按如下方式更新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 自定义资源
AtlasDeployment 自定义资源在Atlas中配置MongoDB 集群或 Flex集群。 当您创建 AtlasDeployment 自定义资源时, Atlas Kubernetes Operator会尝试在Atlas中创建或更新集群或 Flex集群。
Atlas Kubernetes Operator 根据您在AtlasDeployment自定义资源中指定的值执行以下操作之一:
If you specify values for fields under
spec.deploymentSpec, Atlas Kubernetes Operator uses the Atlas Clusters API Resource to create a new cluster or update an existing cluster.If you specify values for fields under
spec.flexSpec, Atlas Kubernetes Operator uses the Atlas Flex Instance API Resource to create a new Flex cluster or update an existing Flex cluster.
注意
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
Flex 集群示例
过渡到 Flex 集群的注意事项
在 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
M2andM5clusters.您无法在Atlas中创建 新的
M2/M5集群和无服务器实例。尝试这样做会创建一个 Flex集群。即使现有的无服务器实例自 2 月初 2025起已弃用,您仍可在Atlas Kubernetes Operator中使用现有的无服务器实例。
For your existing Serverless instances, you can choose to replace references to
spec.serverlessSpecin the AtlasDeployment with the configuration forspec.flexSpec. Or, you can continue using the same spec. Managing a deployment via thespec.serverlessSpecin theAtlasDeploymentCustom Resource will continue to work even once Atlas automatically migrates these existing clusters to Flex clusters in March 2025.For your existing
M2andM5clusters, you can choose to replace references tospec.deploymentSpecin theAtlasDeploymentCustom Resource with the configuration forspec.flexSpec. Or, you can continue using the same spec. Managing a deployment via thespec.deploymentSpecin theAtlasDeploymentCustom Resource will continue to work even after Atlas automatically migrated these existingM2andM5clusters to Flex clusters in May 2025.对于现有无服务器实例,如果在协调期间收到与私有端点相关的错误,则必须升级到Atlas Kubernetes Operator 2.7.1,或将
serverlessSpec配置替换为AtlasDeployment自定义资源中的flexSpec配置。对于
M2和M5集群,为避免自动迁移后可能出现的协调错误,请对 CRD 配置进行以下更改:Remove the
spec.deploymentSpec.replicationSpecs.zoneNamesetting.Remove any of the
spec.deploymentSpec.replicationSpecs.regionConfigssettings after the first set of settings.Specify
replicasetonly in thespec.deploymentSpec.clusterType.
Alternatively, replace references to
spec.deploymentSpecin the AtlasDeployment with the configuration forspec.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
Atlas Search索引示例
以下示例显示了配置为集合 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节点示例
以下示例显示了配置用于创建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
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.deploymentSpecorspec.flexSpecin your configuration.有关更改的完整信息,请参阅过渡到 Flex 集群的说明。
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
diskGBin any region, you can't edit this option. To learn more, seespec.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.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
falseto 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.versionReleaseSystemparameter.Atlas 部署一个运行 MongoDB 7.0 的集群。
You omit this parameter and you set the
spec.deploymentSpec.versionReleaseSystemparameter toLTS.Atlas 部署一个运行 MongoDB 7.0 的集群。
Atlas deprecated
M2andM5clusters and Serverless instances. To learn more, see Migration to Flex Clusters. Set thespec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSizeparameter toM0,M2, orM5.您必须部署MongoDB 7.0 或更高版本。
您可以指定此参数。
Atlas 始终使用发布了最新稳定补丁的指定版本部署该集群。
You set the
spec.deploymentSpec.versionReleaseSystemparameter toCONTINUOUS.您必须省略此参数。
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.regionNameorspec.deploymentSpec.replicationSpecs.什么时候应该使用这个参数?
条件必要性Values您正在部署全球集群。
必需
数组中的每个对象都代表 Atlas 部署 集群节点的区域。
您正在部署非全局副本集和分片集群。
Optional
该数组中有一个对象代表 Atlas 部署集群节点的位置。
If you specify this parameter, you must also specify
spec.deploymentSpec.clusterTypeandspec.deploymentSpec.replicationSpecs.numShards.
spec.deploymentSpec.replicationSpecs.numShards类型:整型
可选的
正整数,指定要为分片集群部署的分片数量。
If you use the
spec.deploymentSpec.replicationSpecsparameter, you must set this parameter.Atlas 接受
1至50(含)。 默认值为1。If you specify a value of
1and you setspec.deploymentSpec.clusterTypetoSHARDED, Atlas deploys a single-shard sharded cluster.If you specify
1and you setspec.deploymentSpec.clusterTypetoREPLICASET, Atlas deploys a replica set.不要为生产环境创建单分片的分片集群。单分片的分片集群无法提供与多分片配置相同的优势。
警告
When you use a sharded cluster, MongoDB requires that your applications connect to a
mongosinstance 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'smongos. 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。Set to
trueto enable instance size auto-caling. If enabled, you must specify a value forspec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.maxInstanceSize.设置为
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 setspec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabledtotrue.注意
在启用自动伸缩的情况下,如果您设立的最大实例大小小于数据库部署的当前实例大小,则Atlas会自动将当前实例大小扩展到您指定的最大值。
例如,如果数据库部署的当前实例大小为
M40,而您将最大实例大小设置为M30,则 Atlas 会自动将当前实例大小扩展到M30。If Atlas changes the current instance size and you don't change the
spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSizein 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 setspec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.enabledtotrue.注意
如果您设立的最小实例大小大于启用自动伸缩的数据库部署的当前实例大小,Atlas会自动将当前实例大小扩展到您指定的最小值。
例如,如果数据库部署的当前实例大小为
M10,而您将最小实例大小设置为M30,则 Atlas 会自动将当前实例大小扩展到M30。If Atlas changes the current instance size and you don't change the
spec.deploymentSpec.replicationSpecs.regionConfigs.electableSpecs.instanceSizein 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
M30or 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.minInstanceSizeandspec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.maxInstanceSizewith auto-scaling enabled. To learn more, seespec.deploymentSpec.replicationSpecs.regionConfigs.autoScaling.compute.minInstanceSizeandspec.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.priorityis0.
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 eitherspec.deploymentSpec.replicationSpecs.regionConfigs.regionNameorspec.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.clusterTypetoGEOSHARDED.
spec.deploymentSpec.searchIndexes类型:数组
Optional
SearchIndex对象的数组,其中包含描述Atlas Search索引的字段。 每个SearchIndex对象都包含以下字段:字段类型说明name字符串
标识此索引的人类可读标签。 对于部署必须是唯一的。
DBName字符串
人类可读标签,用于标识包含具有一个或多个 Atlas Search 索引的集合的现有数据库。
重要提示:您指定的数据库必须已经存在。 如果您没有现有数据库,请创建一个。
collectionName字符串
可读标签,用于标识包含一个或多个 Atlas Search 索引的集合。
type字符串
索引的类型。Atlas 接受以下值:
searchvectorSearch
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,则为必填项。fieldsJSON/YAML
Atlas Search 索引的一个或多个字段规范。 如果省略 mappings.dynamic 或设置为 false,则为必填项。
spec.deploymentSpec.searchIndexes.vectorSearch类型:对象
Optional
字段类型说明fieldsJSON/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_NVMES30_HIGHCPU_NVMES40_HIGHCPU_NVMES50_HIGHCPU_NVMES60_HIGHCPU_NVMES70_HIGHCPU_NVMES80_HIGHCPU_NVMES30_LOWCPU_NVMES40_LOWCPU_NVMES50_LOWCPU_NVMES60_LOWCPU_NVMES80_LOWCPU_NVMES90_LOWCPU_NVMES100_LOWCPU_NVME
默认实例大小为
S20_HIGHCPU_NVME。
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 thespec.deploymentSpec.mongoDBMajorVersionparameter. 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 thespec.deploymentSpec.mongoDBMajorVersionparameter.
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.deploymentSpecorspec.flexSpecin your configuration.
spec.flexSpec.terminationProtectionEnabled类型:布尔值
指示是否为 Flex集群启用或禁用了终止保护。 如果设立为
true, Atlas不会删除集群。 如果设立为false, Atlas将删除集群。 默认值为false。
spec.flexSpec.providerSettings.backingProviderName类型:字符串
Flex集群的云提供商名称。
providerSettings包括为运行MongoDB的预配主机指定设置的配置。Atlas接受以下值之一:
AWSAZUREGCP
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,mongodwrites documents that exceed this limit, but doesn't index them.This option corresponds to the
param.failIndexKeyTooLongmongodparameter.
spec.processArgs.javascriptEnabled类型:布尔值
Optional
指示集群是否允许执行服务器端执行 JavaScript 的操作的标志。
- This option corresponds to modifying the
security.javascriptEnabledconfiguration file option for eachmongodandmongosin the cluster.
spec.processArgs.minimumEnabledTlsProtocol类型:整型
Optional
字符串,表示集群接受的传入连接的最低 TLS 版本。使用 TLS 1.0 或 1.1 的集群应考虑将 TLS 1.2 设置为最低 TLS 协议版本。
要了解更多信息,请参阅Atlas 支持哪些 TLS 版本?
This option corresponds to the
net.ssl.disabledProtocolsmongodconfiguration file option.
spec.processArgs.noTableScan类型:布尔值
Optional
该标志指示集群是否禁用执行需要集合扫描才能返回结果的查询。
This option corresponds to the
notablescanmongodparameter.
spec.processArgs.oplogSizeMB类型:整型
Optional
指示集群 oplog 存储限制的数字,以兆字节为单位。 值为
null表示集群使用 Atlas 计算的默认 oplog 大小。This option corresponds to the
replication.oplogSizeMBmongodconfiguration 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.DiskIOPSspec.serverlessSpec.providerSettings.DiskTypeNamespec.serverlessSpec.providerSettings.EncryptEBSVolumespec.serverlessSpec.providerSettings.InstanceSizeNamespec.serverlessSpec.providerSettings.VolumeTypespec.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 无服务器实例的物理位置。 您选择的区域会影响客户端访问数据库的网络延迟。
有关区域名称值的完整列表,请参阅云提供商参考页面:
status.connectionStrings类型:数组
必需
列表,其中包含用于访问集群的连接 URL。 该参数会在创建或更新集群后出现。
注意
.. include:: /includes/fact-ak8so-connection-strings.rst
有关可通过 API 获取的集群配置参数,请参阅“Atlas 集群 API”。