重要
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.externalMembersType: array of
ExternalMemberobjects迁移中的虚拟机或裸机源进程。此字段仅用于迁移。
You may remove entries from this list, but you must never add entries once migration has started. An empty
spec.externalMemberslist means the migration is complete.
spec.externalMembers[].processName类型:字符串
必需
This field exists for migration only. The process name exactly as it appears in the
processesarray of the automation config.
spec.externalMembers[].hostname类型:字符串
必需
This field exists for migration only. The
host:portvalue for the process, exactly as it appears in the automation config.
名称覆盖
这些字段仅用于迁移,并覆盖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-mckplugin sets this field for you through its--resource-name-overrideflag.
spec.shardNameOverridesType: array of
ShardNameOverrideobjectsThis field exists for migration only. Per-shard automation config replica set name and shard
_id.注意
Do not confuse
spec.shardNameOverrideswithspec.shardOverrides.spec.shardOverridesconfigures per-shard resource settings and is unrelated to migration naming.Kubernetes
StatefulSetnames are never affected by these overrides.
可配置的自动化配置路径
Kubernetes Operator 之前对这些自动化配置设置进行了硬编码。迁移要求它们可配置,以便Kubernetes部署可以匹配源虚拟机上已在使用的路径。
spec.downloadBase类型:字符串
默认值:
/var/lib/mongodb-mms-automationDirectory 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-pemKubernetes 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
podTemplatevolume 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.autoPEMKeyFilePathvalue, and mounts the secret referenced byspec.security.authentication.agents.clientCertificateSecretRefat that path.Requires
spec.security.authentication.agents.clientCertificateSecretRef.默认为Kubernetes Operator 用于非迁移部署的哈希派生代理证书挂载路径。
状态条件
status.conditionsType: array of Kubernetes Conditions
Standard Kubernetes conditions, keyed by
type. This field is new on theMongoDBresource and supports migration.
status.conditions[type=Migrating]类型: Kubernetes条件
The top-level indicator of whether a migration is active.
statusisTruewhilespec.externalMembersis non-empty, and flips toFalsewith reasonMigrationCompleteonce you remove the last external member.原因状态含义ValidatingTrue已设立试运行注解。
ExtendingTrue所需的Kubernetes成员数超过了上次核对的数量。
PruningTrueThe
externalMemberscount dropped belowstatus.migrationObservedExternalMembersCount.InProgressTrue外部成员存在,但没有任何变化。这也是第一次和解的原因。
MigrationCompleteFalse所有外部成员均已删除。
Precedence is
Validating>Extending>Pruning>InProgress. A prune that also grows the Kubernetes side reportsExtending, which is another reason to make one change at a time.不允许同时进行剪枝和扩展。
To script against migration completion, use
kubectl wait --for=condition=Migrating=Falserather than pollingstatus.phase.
status.conditions[type=NetworkConnectivityVerified]Type: Kubernetes condition
The result of the dry-run connectivity check. Kubernetes Operator removes this condition from
status.conditionsentirely once no external members remain.验证器作业退出代码条件状态原因含义作业仍在运行
UnknownRunningThe
status.phaseisConnectivityCheckRunning.0TrueNetworkValidationPassed所有外部成员均可访问并通过身份验证。
2FalseAuthenticationFailedCredentials, the authentication mechanism, or a missing
__system@localrole.3FalseNetworkFailedDNS、TLS、超时或无法访问的成员。检查作业 Pod 日志。
1或其他FalseUnknownError未分类故障。检查作业 Pod 日志。
Failures that occur before the Job starts use the reasons
OperatorImageUnknown,BuildStatefulSetOptions,AgentCertSecretFailed, andAgentCertSubject.Kubernetes Operator removes the
NetworkConnectivityVerifiedcondition fromstatus.conditionsentirely once no external members remain.
status.migrationObservedExternalMembersCount类型:整型
The number of
spec.externalMembersentries that Kubernetes Operator observed on the last reconcile. Kubernetes Operator compares this value against the currentspec.externalMemberscount 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
MongoDBOpsManagercustom resource schema, as a side effect of Go struct embedding. On theMongoDBOpsManagerresource, the field is always null. Ignore it there.
注解
metadata.annotations.mongodb.com/migration-dry-run类型:字符串(布尔值)
The
kubectl mongodb migrate-to-mckplugin sets this annotation totrue. While this annotation is present, Kubernetes Operator makes no automation config changes and performs connectivity validation only. Removing the annotation starts the real migration.
需要针对特定迁移关注的相关字段
The following existing MongoDB resource fields are not migration-only, but require specific values or review during a migration:
spec.members,spec.mongodsPerShardCount,spec.configServerCount, andspec.mongosCountall start at0in the resource that thekubectl mongodb migrate-to-mckplugin generates.spec.memberConfig[].votes(integer, default1) andspec.memberConfig[].priority(string containing a float, default"1"). You must provide at least as manyspec.memberConfigentries asspec.members. Kubernetes Operator ignores the top-levelspec.memberConfigfor sharded clusters. Thekubectl mongodb migrate-to-mckplugin does not generatespec.memberConfig, and Kubernetes Operator does not default new members to non-voting, so the CRD defaults of1and"1"are exactly wrong while a new member is syncing.警告
在增加节点数之前设置 spec.memberConfig
By default, new Kubernetes members join as voting members. The CRD defaults are
votes: 1andpriority: "1", which let a still-syncing member participate in an election before it has finished its initial sync.MongoDB recommends that you write one
spec.memberConfigentry per new Kubernetes member withvotes: 0andpriority: "0"before you raise the member count, so that a still-syncing member cannot win an election.votesis an integer.priorityis a string.Fields that must match the source deployment exactly:
spec.version,spec.featureCompatibilityVersion,spec.additionalMongodConfig.net.port,spec.security.authentication.modes, andspec.security.authentication.internalCluster.