You can deploy an Ops Manager resource that uses an external Application Database: a MongoDB custom resource with spec.role set to AppDB, which a second Ops Manager instance manages as a project. This lets Ops Manager back up and restore the Application Database. To learn more, see Back Up the Ops Manager Application Database.
This procedure deploys a new Ops Manager instance. To convert an existing Ops Manager instance that uses an internally managed Application Database, see Migrate an Application Database to an External Deployment.
Este procedimiento despliega los siguientes recursos:
Una instancia de Ops Manager de gestión con su propia base de datos de aplicaciones gestionada internamente. Esta instancia gestiona el proyecto que contiene la base de datos de aplicaciones externa.
An external Application Database: a MongoDB replica set with
spec.roleset toAppDB, named<primary-om-name>-db.A primary Ops Manager instance that omits
spec.applicationDatabaseand references the external Application Database withspec.externalApplicationDatabaseRef.
Requisitos previos
Antes de comenzar, cumpla con las siguientes tareas:
Deploy a Kubernetes cluster with a default
StorageClass.Install
kubectlandhelmand configure them for that cluster.Obtenga acceso al gráfico Helm del operador de Kubernetes.
Considerations
Configure la versión de Ops Manager y la versión de Application Database para que coincidan. La instancia de Ops Manager administra la base de datos de la aplicación externa, por lo que la versión de Application Database debe ser una versión de MongoDB que la instancia de Ops Manager ofrezca en su manifiesto de versiones. Por ejemplo, una instancia de Ops Manager 8.0.x ofrece versiones de MongoDB 8.0.x, pero una instancia de Ops Manager 7.0.x no.
Procedimiento
Configura las variables de entorno para el despliegue.
export K8S_CTX="<your-kube-context>" export MDB_NS="mongodb" export OPERATOR_HELM_CHART="oci://quay.io/mongodb/helm-charts/mongodb-kubernetes" export OM_VERSION="8.0.7" export APPDB_VERSION="8.0.5-ent" export MANAGEMENT_OM_NAME="management-om" export PRIMARY_OM_NAME="primary-om" export APPDB_NAME="${PRIMARY_OM_NAME}-db" export MANAGEMENT_OM_URL="http://${MANAGEMENT_OM_NAME}-svc.${MDB_NS}.svc.cluster.local:8080" export MANAGEMENT_OM_ADMIN_KEY_SECRET="${MDB_NS}-${MANAGEMENT_OM_NAME}-admin-key" export APPDB_PROJECT_CONFIGMAP="${APPDB_NAME}-config" export APPDB_PROJECT_NAME="external-appdb" export APPDB_CONNECTION_STRING_SECRET="${APPDB_NAME}-connection-string" export OM_ADMIN_EMAIL="admin@example.com" export OM_ADMIN_PASSWORD="<your-password>" export OM_ADMIN_FIRST_NAME="Admin" export OM_ADMIN_LAST_NAME="User"
The Kubernetes Operator requires the external Application Database to be named <primary-om-name>-db, which is why APPDB_NAME derives from PRIMARY_OM_NAME.
Cree el secreto de administrador de Ops Manager.
Both Ops Manager resources reference this secret with spec.adminCredentials.
kubectl create secret generic ops-manager-admin-secret \ --context "${K8S_CTX}" -n "${MDB_NS}" \ --from-literal=Username="${OM_ADMIN_EMAIL}" \ --from-literal=Password="${OM_ADMIN_PASSWORD}" \ --from-literal=FirstName="${OM_ADMIN_FIRST_NAME}" \ --from-literal=LastName="${OM_ADMIN_LAST_NAME}"
Implemente la instancia de administración de Ops Manager.
kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF apiVersion: mongodb.com/v1 kind: MongoDBOpsManager metadata: name: ${MANAGEMENT_OM_NAME} spec: replicas: 1 version: ${OM_VERSION} adminCredentials: ops-manager-admin-secret applicationDatabase: members: 3 version: ${APPDB_VERSION} backup: enabled: false configuration: automation.versions.source: mongodb mms.ignoreInitialUiSetup: "true" mms.adminEmailAddr: admin@example.com mms.fromEmailAddr: admin@example.com mms.replyToEmailAddr: admin@example.com mms.mail.hostname: email-smtp.us-east-1.amazonaws.com mms.mail.port: "465" mms.mail.ssl: "true" mms.mail.transport: smtp mms.minimumTLSVersion: TLSv1.2 EOF
The mms.* mail settings are required. When mms.ignoreInitialUiSetup is true, the Ops Manager pre-flight check doesn't start Ops Manager unless mms.fromEmailAddr and the related mail settings are present.
Espere a que la instancia de Ops Manager esté lista.
Espere a que se carguen la base de datos de la aplicación gestionada internamente y el recurso del administrador de operaciones:
kubectl wait --for=jsonpath='{.status.applicationDatabase.phase}'=Running \ om/"${MANAGEMENT_OM_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" --timeout=1200s kubectl wait --for=jsonpath='{.status.opsManager.phase}'=Running \ om/"${MANAGEMENT_OM_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" --timeout=1800s Confirm that the Ops Manager public API answers requests. An
opsManager.phaseofRunningmeans that the Ops Manager pod is up, but the API that the Kubernetes Operator uses to create the Application Database project can lag by a few seconds. A401response is the expected unauthenticated response and means that the API is ready:om_pod="${MANAGEMENT_OM_NAME}-0" until [ "$(kubectl exec "${om_pod}" -c mongodb-ops-manager --context "${K8S_CTX}" -n "${MDB_NS}" -- \ curl -s -o /dev/null -w '%{http_code}' \ "http://$(kubectl get pod "${om_pod}" --context "${K8S_CTX}" -n "${MDB_NS}" \ -o jsonpath='{.status.podIP}'):8080/api/public/v1.0" 2>/dev/null)" = "401" ]; do echo "waiting for management Ops Manager public API..."; sleep 10 done Confirm that the Kubernetes Operator created the programmatic API key secret for the management Ops Manager instance:
kubectl get secret "${MANAGEMENT_OM_ADMIN_KEY_SECRET}" \ --context "${K8S_CTX}" -n "${MDB_NS}"
Cree la base de datos de la aplicación externa.
kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: ${APPDB_NAME} spec: members: 3 version: ${APPDB_VERSION} type: ReplicaSet role: AppDB opsManager: configMapRef: name: ${APPDB_PROJECT_CONFIGMAP} credentials: ${MANAGEMENT_OM_ADMIN_KEY_SECRET} persistent: true EOF kubectl wait --for=jsonpath='{.status.phase}'=Running \ mdb/"${APPDB_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" --timeout=1200s
When you set spec.role to AppDB, the Kubernetes Operator configures SCRAM authentication for the resource. To learn more, see spec.role.
Implemente la instancia principal de Ops Manager.
This resource omits spec.applicationDatabase and references the external Application Database instead.
kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF apiVersion: mongodb.com/v1 kind: MongoDBOpsManager metadata: name: ${PRIMARY_OM_NAME} spec: replicas: 1 version: ${OM_VERSION} adminCredentials: ops-manager-admin-secret externalApplicationDatabaseRef: name: ${APPDB_NAME} kind: MongoDB backup: enabled: false configuration: automation.versions.source: mongodb mms.ignoreInitialUiSetup: "true" mms.adminEmailAddr: admin@example.com mms.fromEmailAddr: admin@example.com mms.replyToEmailAddr: admin@example.com mms.mail.hostname: email-smtp.us-east-1.amazonaws.com mms.mail.port: "465" mms.mail.ssl: "true" mms.mail.transport: smtp mms.minimumTLSVersion: TLSv1.2 EOF
To enable backup for your MongoDB deployments, set spec.backup.enabled to true on this resource and configure snapshot storage. To learn more, see Configure File System Backup Store with Kubernetes Operator.
Espere a que la instancia principal de Ops Manager esté lista.
kubectl wait --for=jsonpath='{.status.opsManager.phase}'=Running \ om/"${PRIMARY_OM_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" --timeout=1800s kubectl wait --for=jsonpath='{.status.applicationDatabase.phase}'=Disabled \ om/"${PRIMARY_OM_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" --timeout=600s
The Kubernetes Operator doesn't manage an internal Application Database for an Ops Manager resource that uses an external Application Database, so status.applicationDatabase.phase reports Disabled. This is expected and isn't an error.
Verifique la implementación.
Confirme que los pods de administración de Ops Manager, los pods de la base de datos de aplicaciones externa y los pods principales de Ops Manager estén en ejecución:
kubectl get pods --context "${K8S_CTX}" -n "${MDB_NS}" Confirme que el recurso MongoDB es propietario del StatefulSet de la base de datos de la aplicación y que el recurso principal del Administrador de operaciones no lo es:
kubectl get statefulset "${APPDB_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" \ -o jsonpath='{range .metadata.ownerReferences[*]}{.kind}/{.name}{"\n"}{end}' The command returns
MongoDB/${APPDB_NAME}.Confirme que el operador de Kubernetes creó la cadena secreta de conexión para la instancia principal de Ops Manager:
kubectl get secret "${APPDB_CONNECTION_STRING_SECRET}" \ --context "${K8S_CTX}" -n "${MDB_NS}"
Problemas comunes en las bases de datos de aplicaciones externas
El recurso MongoDB informa un error de versión.
If the external Application Database reports Failed with a message that the MongoDB version isn't available, set spec.version to a version that the management Ops Manager instance offers. Keep the Ops Manager version and the Application Database version on the same major version. The management Ops Manager instance's own internally managed Application Database isn't affected, because it downloads binaries directly when you set automation.versions.source to mongodb.
La base de datos de la aplicación externa permanece pendiente.
If the external Application Database stays in the Pending phase and the MongoDB Agent never receives an automation configuration, you might have created the MongoDB resource before the management Ops Manager public API was serving requests. The Kubernetes Operator couldn't create the project. Confirm that the API readiness check returns 401, then reconcile the resource again.
El operador rechaza la referencia a la base de datos de la aplicación externa.
The value of spec.externalApplicationDatabaseRef.name must be exactly <primary-om-name>-db, and the MongoDB resource must be in the same namespace as the Ops Manager resource.
Próximos pasos
To back up the external Application Database, enable backup on the MongoDB resource in the project that the management Ops Manager instance manages. To learn more, see Configure MongoDB Database Backups.