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

MongoDB迁移资源设置

重要

The settings on this page exist to support migrating a self-managed deployment into Kubernetes under Kubernetes Operator. Do not set them on a MongoDB resource that you deploy directly in Kubernetes without an accompanying migration.

This page documents the MongoDB resource fields, status conditions, and annotations that apply only during a migration from a self-managed, virtual-machine deployment into Kubernetes. For the full set of MongoDB resource settings, see MongoDB Database Resource Specification.

These fields identify the source virtual machine or bare-metal processes that a migration is extending into Kubernetes. They apply to the MongoDB resource, apiVersion: mongodb.com/v1.

重要

These fields exist for migration only. Do not set them on a MongoDB resource for a greenfield Kubernetes deployment.

spec.externalMembers

Type: array of ExternalMember objects

迁移中的虚拟机或裸机源进程。此字段仅用于迁移。

You may remove entries from this list, but you must never add entries once migration has started. An empty spec.externalMembers list means the migration is complete.

spec.externalMembers[].processName

类型:字符串

必需

This field exists for migration only. The process name exactly as it appears in the processes array of the automation config.

spec.externalMembers[].hostname

类型:字符串

必需

This field exists for migration only. The host:port value for the process, exactly as it appears in the automation config.

spec.externalMembers[].type

Type: enum: mongod or mongos

对于分片的集群是必需的

This field exists for migration only. A replica set has only mongod external members.

spec.externalMembers[].replicaSetName

类型:字符串

Optional

This field exists for migration only. Required for a sharded-cluster mongod external member. Identifies whether the process belongs to the config server replica set or to a specific shard's replica set.

这些字段仅用于迁移,并覆盖Kubernetes Operator 使用或生成的资源或自动化配置名称。

spec.replicaSetNameOverride

类型:字符串

This field exists for migration only. The automation config replica set name, when it differs from the Kubernetes resource name, or when the automation config replica set name is not a valid Kubernetes name. The kubectl mongodb migrate-to-mck plugin sets this field for you through its --resource-name-override flag.

spec.configServerNameOverride

类型:字符串

此字段仅用于迁移。自动化配置中显示的配置服务器副本集名称。

spec.shardNameOverrides

Type: array of ShardNameOverride objects

This field exists for migration only. Per-shard automation config replica set name and shard _id.

注意

Do not confuse spec.shardNameOverrides with spec.shardOverrides. spec.shardOverrides configures per-shard resource settings and is unrelated to migration naming.

Kubernetes StatefulSet names are never affected by these overrides.

Kubernetes Operator 之前对这些自动化配置设置进行了硬编码。迁移要求它们可配置,以便Kubernetes部署可以匹配源虚拟机上已在使用的路径。

spec.downloadBase

类型:字符串

默认值/var/lib/mongodb-mms-automation

Directory where the MongoDB Agent downloads the agent binary. Kubernetes Operator derives the keyfile path from this setting as <downloadBase>/keyfile.

spec.security.tls.caFilePath

类型:字符串

默认值/mongodb-automation/tls/ca/ca-pem

Kubernetes Operator 在 Pod 内投影 CA 证书的绝对路径。此路径必须包含至少两个路径段。不支持应用程序数据库。

注意

If your pod template mounts a volume at or above this path, the mount can shadow the projected CA file. Review your podTemplate volume mounts before you set a custom value.

spec.security.authentication.agents.autoPEMKeyFilePath

类型:字符串

Absolute path of the MongoDB Agent's combined PEM file inside database pods. Setting this field sets the Ops Manager or Cloud Manager tls.autoPEMKeyFilePath value, and mounts the secret referenced by spec.security.authentication.agents.clientCertificateSecretRef at that path.

Requires spec.security.authentication.agents.clientCertificateSecretRef.

默认为Kubernetes Operator 用于非迁移部署的哈希派生代理证书挂载路径。

status.conditions

Type: array of Kubernetes Conditions

Standard Kubernetes conditions, keyed by type. This field is new on the MongoDB resource and supports migration.

status.conditions[type=Migrating]

类型: Kubernetes条件

The top-level indicator of whether a migration is active. status is True while spec.externalMembers is non-empty, and flips to False with reason MigrationComplete once you remove the last external member.

原因
状态
含义

Validating

True

已设立试运行注解。

Extending

True

所需的Kubernetes成员数超过了上次核对的数量。

Pruning

True

The externalMembers count dropped below status.migrationObservedExternalMembersCount.

InProgress

True

外部成员存在,但没有任何变化。这也是第一次和解的原因。

MigrationComplete

False

所有外部成员均已删除。

Precedence is Validating > Extending > Pruning > InProgress. A prune that also grows the Kubernetes side reports Extending, which is another reason to make one change at a time.

不允许同时进行剪枝和扩展。

To script against migration completion, use kubectl wait --for=condition=Migrating=False rather than polling status.phase.

status.conditions[type=NetworkConnectivityVerified]

Type: Kubernetes condition

The result of the dry-run connectivity check. Kubernetes Operator removes this condition from status.conditions entirely once no external members remain.

验证器作业退出代码
条件状态
原因
含义

作业仍在运行

Unknown

Running

The status.phase is ConnectivityCheckRunning.

0

True

NetworkValidationPassed

所有外部成员均可访问并通过身份验证。

2

False

AuthenticationFailed

Credentials, the authentication mechanism, or a missing __system@local role.

3

False

NetworkFailed

DNS、TLS、超时或无法访问的成员。检查作业 Pod 日志。

1 或其他

False

UnknownError

未分类故障。检查作业 Pod 日志。

Failures that occur before the Job starts use the reasons OperatorImageUnknown, BuildStatefulSetOptions, AgentCertSecretFailed, and AgentCertSubject.

Kubernetes Operator removes the NetworkConnectivityVerified condition from status.conditions entirely once no external members remain.

status.migrationObservedExternalMembersCount

类型:整型

The number of spec.externalMembers entries that Kubernetes Operator observed on the last reconcile. Kubernetes Operator compares this value against the current spec.externalMembers count on the next reconcile to detect that you pruned an external member. This field is unset when no external members remain.

注意

This field also appears in the MongoDBOpsManager custom resource schema, as a side effect of Go struct embedding. On the MongoDBOpsManager resource, the field is always null. Ignore it there.

metadata.annotations.mongodb.com/migration-dry-run

类型:字符串(布尔值)

The kubectl mongodb migrate-to-mck plugin sets this annotation to true. While this annotation is present, Kubernetes Operator makes no automation config changes and performs connectivity validation only. Removing the annotation starts the real migration.

metadata.annotations.mongodb.com/migrate-tool-version

类型:字符串

Records the version of the kubectl mongodb migrate-to-mck plugin that generated the resource. Kubernetes Operator validates this annotation against its own version on every reconcile, including during the dry run.

The following existing MongoDB resource fields are not migration-only, but require specific values or review during a migration: