For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB Migration Resource Settings

Important

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.

Important

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

The virtual machine or bare-metal source processes that are part of the migration. This field exists for migration only.

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

Type: string

Required

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

spec.externalMembers[].hostname

Type: string

Required

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

Required for sharded clusters

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

spec.externalMembers[].replicaSetName

Type: string

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.

These fields exist for migration only, and override the resource or automation config name that Kubernetes Operator would otherwise use or generate.

spec.replicaSetNameOverride

Type: string

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

Type: string

This field exists for migration only. The config server replica set name as it appears in the automation config.

spec.shardNameOverrides

Type: array of ShardNameOverride objects

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

Note

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 previously hard-coded these automation config settings. Migration requires them to be configurable so that a Kubernetes deployment can match paths already in use on the source virtual machines.

spec.downloadBase

Type: string

Default: /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

Type: string

Default: /mongodb-automation/tls/ca/ca-pem

Absolute path where Kubernetes Operator projects the CA certificate inside the pod. This path must contain at least two path segments. Not supported for the Application Database.

Note

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

Type: string

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.

Defaults to the hash-derived agent certificate mount path that Kubernetes Operator uses for non-migrated deployments.

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]

Type: Kubernetes condition

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.

Reason
Status
Meaning

Validating

True

The dry-run annotation is set.

Extending

True

The desired Kubernetes member count exceeds the last reconciled count.

Pruning

True

The externalMembers count dropped below status.migrationObservedExternalMembersCount.

InProgress

True

External members exist but nothing is changing. This is also the reason on the first reconcile.

MigrationComplete

False

All external members have been removed.

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.

Pruning and extending are not allowed at the same 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.

Validator Job Exit Code
Condition Status
Reason
Meaning

Job still running

Unknown

Running

The status.phase is ConnectivityCheckRunning.

0

True

NetworkValidationPassed

All external members are reachable and authenticated.

2

False

AuthenticationFailed

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

3

False

NetworkFailed

DNS, TLS, timeouts, or unreachable members. Check the Job Pod logs.

1 or other

False

UnknownError

Unclassified failure. Check the Job Pod logs.

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

Type: integer

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.

Note

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

Type: string (boolean value)

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

Type: string

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: