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.
External Members
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.externalMembersType: array of
ExternalMemberobjectsThe 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.externalMemberslist means the migration is complete.
spec.externalMembers[].processNameType: string
Required
This field exists for migration only. The process name exactly as it appears in the
processesarray of the automation config.
spec.externalMembers[].hostnameType: string
Required
This field exists for migration only. The
host:portvalue for the process, exactly as it appears in the automation config.
Name Overrides
These fields exist for migration only, and override the resource or automation config name that Kubernetes Operator would otherwise use or generate.
spec.replicaSetNameOverrideType: 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-mckplugin sets this field for you through its--resource-name-overrideflag.
spec.configServerNameOverrideType: string
This field exists for migration only. The config server replica set name as it appears in the automation config.
spec.shardNameOverridesType: array of
ShardNameOverrideobjectsThis field exists for migration only. Per-shard automation config replica set name and shard
_id.Note
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.
Configurable Automation Config Paths
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.downloadBaseType: string
Default:
/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.caFilePathType: string
Default:
/mongodb-automation/tls/ca/ca-pemAbsolute 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
podTemplatevolume mounts before you set a custom value.
spec.security.authentication.agents.autoPEMKeyFilePathType: 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.autoPEMKeyFilePathvalue, and mounts the secret referenced byspec.security.authentication.agents.clientCertificateSecretRefat 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
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]Type: Kubernetes condition
The top-level indicator of whether a migration is active.
statusisTruewhilespec.externalMembersis non-empty, and flips toFalsewith reasonMigrationCompleteonce you remove the last external member.ReasonStatusMeaningValidatingTrueThe dry-run annotation is set.
ExtendingTrueThe desired Kubernetes member count exceeds the last reconciled count.
PruningTrueThe
externalMemberscount dropped belowstatus.migrationObservedExternalMembersCount.InProgressTrueExternal members exist but nothing is changing. This is also the reason on the first reconcile.
MigrationCompleteFalseAll external members have been removed.
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.Pruning and extending are not allowed at the same 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.Validator Job Exit CodeCondition StatusReasonMeaningJob still running
UnknownRunningThe
status.phaseisConnectivityCheckRunning.0TrueNetworkValidationPassedAll external members are reachable and authenticated.
2FalseAuthenticationFailedCredentials, the authentication mechanism, or a missing
__system@localrole.3FalseNetworkFailedDNS, TLS, timeouts, or unreachable members. Check the Job Pod logs.
1or otherFalseUnknownErrorUnclassified failure. Check the Job Pod logs.
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.migrationObservedExternalMembersCountType: integer
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.Note
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.
Annotations
metadata.annotations.mongodb.com/migration-dry-runType: string (boolean value)
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.
Related Fields That Need Migration-Specific Attention
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.Warning
Set spec.memberConfig before you raise the member count
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.