diff --git a/.evergreen-tasks.yml b/.evergreen-tasks.yml index cb502c0cd..ad31aa617 100644 --- a/.evergreen-tasks.yml +++ b/.evergreen-tasks.yml @@ -84,7 +84,13 @@ tasks: - func: test_code_snippets - func: sample_commit_output - - name: task_kind_community_search_snippets + - name: task_kind_search_community_snippets + tags: [ "code_snippets", "patch-run" ] + commands: + - func: test_code_snippets + - func: sample_commit_output + + - name: task_kind_search_enterprise_snippets tags: [ "code_snippets", "patch-run" ] commands: - func: test_code_snippets diff --git a/.evergreen.yml b/.evergreen.yml index 8937f8def..8be88e9db 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -104,9 +104,12 @@ variables: - func: download_kube_tools - func: configure_docker_auth - func: setup_kubernetes_environment + - func: setup_cloud_qa teardown_task: - func: upload_e2e_logs - func: upload_code_snippets_logs + - func: teardown_kubernetes_environment + - func: teardown_cloud_qa - &setup_and_teardown_task_cloudqa setup_task_can_fail_task: true @@ -676,7 +679,8 @@ task_groups: <<: *setup_and_teardown_group_kind_code_snippets max_hosts: -1 tasks: - - task_kind_community_search_snippets + - task_kind_search_community_snippets + - task_kind_search_enterprise_snippets # Task group for deploying mongodbcommunity resources and testing the (former) MCO - name: e2e_mdb_community_task_group diff --git a/docs/community-search/quick-start/README.md b/docs/search/community/quick-start/README.md similarity index 100% rename from docs/community-search/quick-start/README.md rename to docs/search/community/quick-start/README.md diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/search/community/quick-start/README.md.j2 similarity index 100% rename from docs/community-search/quick-start/README.md.j2 rename to docs/search/community/quick-start/README.md.j2 diff --git a/docs/community-search/quick-start/code_snippets/0045_create_namespaces.sh b/docs/search/community/quick-start/code_snippets/0045_create_namespaces.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0045_create_namespaces.sh rename to docs/search/community/quick-start/code_snippets/0045_create_namespaces.sh diff --git a/docs/community-search/quick-start/code_snippets/0046_create_image_pull_secrets.sh b/docs/search/community/quick-start/code_snippets/0046_create_image_pull_secrets.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0046_create_image_pull_secrets.sh rename to docs/search/community/quick-start/code_snippets/0046_create_image_pull_secrets.sh diff --git a/docs/community-search/quick-start/code_snippets/0100_install_operator.sh b/docs/search/community/quick-start/code_snippets/0100_install_operator.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0100_install_operator.sh rename to docs/search/community/quick-start/code_snippets/0100_install_operator.sh diff --git a/docs/community-search/quick-start/code_snippets/0305_create_mongodb_community_user_secrets.sh b/docs/search/community/quick-start/code_snippets/0305_create_mongodb_community_user_secrets.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0305_create_mongodb_community_user_secrets.sh rename to docs/search/community/quick-start/code_snippets/0305_create_mongodb_community_user_secrets.sh diff --git a/docs/community-search/quick-start/code_snippets/0310_create_mongodb_community_resource.sh b/docs/search/community/quick-start/code_snippets/0310_create_mongodb_community_resource.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0310_create_mongodb_community_resource.sh rename to docs/search/community/quick-start/code_snippets/0310_create_mongodb_community_resource.sh diff --git a/docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh b/docs/search/community/quick-start/code_snippets/0315_wait_for_community_resource.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh rename to docs/search/community/quick-start/code_snippets/0315_wait_for_community_resource.sh diff --git a/docs/community-search/quick-start/code_snippets/0320_create_mongodb_search_resource.sh b/docs/search/community/quick-start/code_snippets/0320_create_mongodb_search_resource.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0320_create_mongodb_search_resource.sh rename to docs/search/community/quick-start/code_snippets/0320_create_mongodb_search_resource.sh diff --git a/docs/community-search/quick-start/code_snippets/0325_wait_for_search_resource.sh b/docs/search/community/quick-start/code_snippets/0325_wait_for_search_resource.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0325_wait_for_search_resource.sh rename to docs/search/community/quick-start/code_snippets/0325_wait_for_search_resource.sh diff --git a/docs/community-search/quick-start/code_snippets/0330_wait_for_community_resource.sh b/docs/search/community/quick-start/code_snippets/0330_wait_for_community_resource.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0330_wait_for_community_resource.sh rename to docs/search/community/quick-start/code_snippets/0330_wait_for_community_resource.sh diff --git a/docs/community-search/quick-start/code_snippets/0335_show_running_pods.sh b/docs/search/community/quick-start/code_snippets/0335_show_running_pods.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0335_show_running_pods.sh rename to docs/search/community/quick-start/code_snippets/0335_show_running_pods.sh diff --git a/docs/community-search/quick-start/code_snippets/0410_run_mongodb_tools_pod.sh b/docs/search/community/quick-start/code_snippets/0410_run_mongodb_tools_pod.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0410_run_mongodb_tools_pod.sh rename to docs/search/community/quick-start/code_snippets/0410_run_mongodb_tools_pod.sh diff --git a/docs/community-search/quick-start/code_snippets/0420_import_movies_mflix_database.sh b/docs/search/community/quick-start/code_snippets/0420_import_movies_mflix_database.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0420_import_movies_mflix_database.sh rename to docs/search/community/quick-start/code_snippets/0420_import_movies_mflix_database.sh diff --git a/docs/community-search/quick-start/code_snippets/0430_create_search_index.sh b/docs/search/community/quick-start/code_snippets/0430_create_search_index.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0430_create_search_index.sh rename to docs/search/community/quick-start/code_snippets/0430_create_search_index.sh diff --git a/docs/community-search/quick-start/code_snippets/0440_wait_for_search_index_ready.sh b/docs/search/community/quick-start/code_snippets/0440_wait_for_search_index_ready.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0440_wait_for_search_index_ready.sh rename to docs/search/community/quick-start/code_snippets/0440_wait_for_search_index_ready.sh diff --git a/docs/community-search/quick-start/code_snippets/0450_execute_search_query.sh b/docs/search/community/quick-start/code_snippets/0450_execute_search_query.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/0450_execute_search_query.sh rename to docs/search/community/quick-start/code_snippets/0450_execute_search_query.sh diff --git a/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh b/docs/search/community/quick-start/code_snippets/090_helm_add_mogodb_repo.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh rename to docs/search/community/quick-start/code_snippets/090_helm_add_mogodb_repo.sh diff --git a/docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh b/docs/search/community/quick-start/code_snippets/9010_delete_namespace.sh similarity index 100% rename from docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh rename to docs/search/community/quick-start/code_snippets/9010_delete_namespace.sh diff --git a/docs/community-search/quick-start/env_variables.sh b/docs/search/community/quick-start/env_variables.sh similarity index 100% rename from docs/community-search/quick-start/env_variables.sh rename to docs/search/community/quick-start/env_variables.sh diff --git a/docs/community-search/quick-start/env_variables_e2e_prerelease.sh b/docs/search/community/quick-start/env_variables_e2e_prerelease.sh similarity index 100% rename from docs/community-search/quick-start/env_variables_e2e_prerelease.sh rename to docs/search/community/quick-start/env_variables_e2e_prerelease.sh diff --git a/docs/community-search/quick-start/env_variables_e2e_private.sh b/docs/search/community/quick-start/env_variables_e2e_private.sh similarity index 100% rename from docs/community-search/quick-start/env_variables_e2e_private.sh rename to docs/search/community/quick-start/env_variables_e2e_private.sh diff --git a/docs/community-search/quick-start/env_variables_e2e_private_dev.sh b/docs/search/community/quick-start/env_variables_e2e_private_dev.sh similarity index 87% rename from docs/community-search/quick-start/env_variables_e2e_private_dev.sh rename to docs/search/community/quick-start/env_variables_e2e_private_dev.sh index 89f8a3932..0834ef77c 100644 --- a/docs/community-search/quick-start/env_variables_e2e_private_dev.sh +++ b/docs/search/community/quick-start/env_variables_e2e_private_dev.sh @@ -27,7 +27,10 @@ declare -a helm_values=( "search.community.version=${search_image_hash}" ) +SCRIPT_PATH="${BASH_SOURCE[0]}" +SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)" + OPERATOR_ADDITIONAL_HELM_VALUES="$(echo -n "${helm_values[@]}" | tr ' ' ',')" export OPERATOR_ADDITIONAL_HELM_VALUES -OPERATOR_HELM_CHART="$(realpath "../../../helm_chart")" +OPERATOR_HELM_CHART="$(realpath "${SCRIPT_DIR}/../../../../helm_chart")" export OPERATOR_HELM_CHART diff --git a/docs/community-search/quick-start/env_variables_e2e_public.sh b/docs/search/community/quick-start/env_variables_e2e_public.sh similarity index 100% rename from docs/community-search/quick-start/env_variables_e2e_public.sh rename to docs/search/community/quick-start/env_variables_e2e_public.sh diff --git a/docs/community-search/quick-start/output/0100_install_operator.out b/docs/search/community/quick-start/output/0100_install_operator.out similarity index 100% rename from docs/community-search/quick-start/output/0100_install_operator.out rename to docs/search/community/quick-start/output/0100_install_operator.out diff --git a/docs/community-search/quick-start/output/0335_show_running_pods.out b/docs/search/community/quick-start/output/0335_show_running_pods.out similarity index 100% rename from docs/community-search/quick-start/output/0335_show_running_pods.out rename to docs/search/community/quick-start/output/0335_show_running_pods.out diff --git a/docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out b/docs/search/community/quick-start/output/0440_wait_for_search_index_ready.out similarity index 100% rename from docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out rename to docs/search/community/quick-start/output/0440_wait_for_search_index_ready.out diff --git a/docs/community-search/quick-start/output/0450_execute_search_query.out b/docs/search/community/quick-start/output/0450_execute_search_query.out similarity index 100% rename from docs/community-search/quick-start/output/0450_execute_search_query.out rename to docs/search/community/quick-start/output/0450_execute_search_query.out diff --git a/docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out b/docs/search/community/quick-start/output/090_helm_add_mogodb_repo.out similarity index 100% rename from docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out rename to docs/search/community/quick-start/output/090_helm_add_mogodb_repo.out diff --git a/docs/community-search/quick-start/test.sh b/docs/search/community/quick-start/test.sh similarity index 91% rename from docs/community-search/quick-start/test.sh rename to docs/search/community/quick-start/test.sh index 86fb6b23e..2975e2141 100755 --- a/docs/community-search/quick-start/test.sh +++ b/docs/search/community/quick-start/test.sh @@ -5,7 +5,7 @@ set -eou pipefail script_name=$(readlink -f "${BASH_SOURCE[0]}") script_dir=$(dirname "${script_name}") -source "${script_dir}/../../../scripts/code_snippets/sample_test_runner.sh" +source "${script_dir}/../../../../scripts/code_snippets/sample_test_runner.sh" cd "${script_dir}" diff --git a/docs/search/enterprise/quick-start/README.md b/docs/search/enterprise/quick-start/README.md new file mode 100644 index 000000000..a963d24ff --- /dev/null +++ b/docs/search/enterprise/quick-start/README.md @@ -0,0 +1,417 @@ +# MongoDB Enterprise Search on Kubernetes - Quick Start + +This guide provides instructions for deploying MongoDB Enterprise Edition along with its Search capabilities onto a Kubernetes cluster. By following these steps, you will set up a MongoDB instance and configure search indexes to perform full-text search queries against your data. + +## Prerequisites + +Before you begin, ensure you have the following tools and configurations in place: + +- **Kubernetes cluster**: A running Kubernetes cluster (e.g., Minikube, Kind, GKE, EKS, AKS) with kubeconfig available locally. +- **kubectl**: The Kubernetes command-line tool, configured to communicate with your cluster. +- **Helm**: The package manager for Kubernetes, used here to install the MongoDB Kubernetes Operator. +- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Scripts in this guide are automatically tested on Linux with Bash 5.1. +- **Ops Manager or Cloud Manager**: Deploying MongoDB Enterprise Edition requires an Ops Manager or Cloud Manager project and API credentials. + +## Setup Steps + +The following steps guide you through deploying MongoDB Enterprise with Search. Each step provides a shell script. +**It is important to first source the `env_variables.sh` script provided and customize its values for your environment.** +The subsequent script snippets rely on the environment variables defined in `env_variables.sh`. You should copy and paste each script into your Bash terminal. + +### 1. Configure Environment Variables + +First, you need to set up your environment. The `env_variables.sh` script, shown below, contains variables for the subsequent steps. You should create this file locally or use the linked one. + +Download or copy the content of `env_variables.sh`: +[env_variables.sh](env_variables.sh) +```shell copy +# set it to the context name of the k8s cluster +export K8S_CLUSTER_0_CONTEXT_NAME="" + +# the following namespace will be created if not exists +export MDB_NAMESPACE="mongodb" + +# minimum required MongoDB version for running MongoDB Search is 8.0.10 +export MDB_VERSION="8.0.10" + +# root admin user for restoring the database from a sample backup +export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME" +# regular user performing search queries on sample mflix database +export MDB_USER_PASSWORD="mdb-user-password-CHANGE-ME" +# user for MongoDB Search to connect to the replica set to synchronise data from +export MDB_SEARCH_SYNC_USER_PASSWORD="search-sync-user-password-CHANGE-ME" + +export MDB_OPS_MANAGER_CONFIG_MAP_NAME="" +export MDB_OPS_MANAGER_CREDENTIALS_SECRET_NAME="" + +export OPERATOR_HELM_CHART="mongodb/mongodb-kubernetes" +# comma-separated key=value pairs for additional parameters passed to the helm-chart installing the operator +export OPERATOR_ADDITIONAL_HELM_VALUES="" +``` +This will load the variables into your current shell session, making them available for the commands in the following steps. + +### 2. Add MongoDB Helm Repository + +First, add the MongoDB Helm repository. This repository contains the Helm chart required to install the MongoDB Kubernetes Operator. The operator automates the deployment and management of MongoDB instances (both Community and Enterprise editions) on Kubernetes. + +[code_snippets/090_helm_add_mogodb_repo.sh](code_snippets/090_helm_add_mogodb_repo.sh) +```shell copy +helm repo add mongodb https://mongodb.github.io/helm-charts +helm repo update mongodb +helm search repo mongodb/mongodb-kubernetes +``` + +### 3. Install MongoDB Kubernetes Operator + +Next, install the MongoDB Kubernetes Operator from the Helm repository you just added. The Operator will watch for MongoDB and MongoDBSearch custom resources and manage the lifecycle of your MongoDB deployments. + +[code_snippets/0100_install_operator.sh](code_snippets/0100_install_operator.sh) +```shell copy +helm upgrade --install --debug --kube-context "${K8S_CLUSTER_0_CONTEXT_NAME}" \ + --create-namespace \ + --namespace="${MDB_NAMESPACE}" \ + mongodb-kubernetes \ + --set "${OPERATOR_ADDITIONAL_HELM_VALUES:-"dummy=value"}" \ + "${OPERATOR_HELM_CHART}" +``` +This command installs the operator in the `mongodb` namespace (creating it if it doesn't exist). + +## Creating a MongoDB Search Deployment + +With the prerequisites and initial setup complete, you can now deploy MongoDB Enterprise Edition and enable Search. + +### 4. Create MongoDB Enterprise Resource + +Now, deploy MongoDB Enterprise by creating a `MongoDB` custom resource named `mdb-rs`. This resource definition instructs the MongoDB Kubernetes Operator to configure a MongoDB replica set with 3 members, running version 8.0.10. MongoDB Search is supported only from MongoDB Enterprise Server version 8.0.10. It also defines CPU and memory resources for the `mongodb-enterprise-database` container, and sets up three users: + + +[code_snippets/0305_create_mongodb_database_resource.sh](code_snippets/0305_create_mongodb_database_resource.sh) +```yaml copy +kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - < /tmp/mdb_script.js +mongosh --quiet "mongodb://mdb-user:${MDB_USER_PASSWORD}@mdb-rs-0.mdb-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdb-rs" < /tmp/mdb_script.js +EOF +)" +``` \ No newline at end of file diff --git a/docs/search/enterprise/quick-start/README.md.j2 b/docs/search/enterprise/quick-start/README.md.j2 new file mode 100644 index 000000000..08ce07d99 --- /dev/null +++ b/docs/search/enterprise/quick-start/README.md.j2 @@ -0,0 +1,179 @@ +# MongoDB Enterprise Search on Kubernetes - Quick Start + +This guide provides instructions for deploying MongoDB Enterprise Edition along with its Search capabilities onto a Kubernetes cluster. By following these steps, you will set up a MongoDB instance and configure search indexes to perform full-text search queries against your data. + +## Prerequisites + +Before you begin, ensure you have the following tools and configurations in place: + +- **Kubernetes cluster**: A running Kubernetes cluster (e.g., Minikube, Kind, GKE, EKS, AKS) with kubeconfig available locally. +- **kubectl**: The Kubernetes command-line tool, configured to communicate with your cluster. +- **Helm**: The package manager for Kubernetes, used here to install the MongoDB Kubernetes Operator. +- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Scripts in this guide are automatically tested on Linux with Bash 5.1. +- **Ops Manager or Cloud Manager**: Deploying MongoDB Enterprise Edition requires an Ops Manager or Cloud Manager project and API credentials. + +## Setup Steps + +The following steps guide you through deploying MongoDB Enterprise with Search. Each step provides a shell script. +**It is important to first source the `env_variables.sh` script provided and customize its values for your environment.** +The subsequent script snippets rely on the environment variables defined in `env_variables.sh`. You should copy and paste each script into your Bash terminal. + +### 1. Configure Environment Variables + +First, you need to set up your environment. The `env_variables.sh` script, shown below, contains variables for the subsequent steps. You should create this file locally or use the linked one. + +Download or copy the content of `env_variables.sh`: +[env_variables.sh](env_variables.sh) +```shell copy +{% include "env_variables.sh" %} +``` +This will load the variables into your current shell session, making them available for the commands in the following steps. + +### 2. Add MongoDB Helm Repository + +First, add the MongoDB Helm repository. This repository contains the Helm chart required to install the MongoDB Kubernetes Operator. The operator automates the deployment and management of MongoDB instances (both Community and Enterprise editions) on Kubernetes. + +[code_snippets/090_helm_add_mogodb_repo.sh](code_snippets/090_helm_add_mogodb_repo.sh) +```shell copy +{% include "code_snippets/090_helm_add_mogodb_repo.sh" %} +``` + +### 3. Install MongoDB Kubernetes Operator + +Next, install the MongoDB Kubernetes Operator from the Helm repository you just added. The Operator will watch for MongoDB and MongoDBSearch custom resources and manage the lifecycle of your MongoDB deployments. + +[code_snippets/0100_install_operator.sh](code_snippets/0100_install_operator.sh) +```shell copy +{% include "code_snippets/0100_install_operator.sh" %} +``` +This command installs the operator in the `mongodb` namespace (creating it if it doesn't exist). + +## Creating a MongoDB Search Deployment + +With the prerequisites and initial setup complete, you can now deploy MongoDB Enterprise Edition and enable Search. + +### 4. Create MongoDB Enterprise Resource + +Now, deploy MongoDB Enterprise by creating a `MongoDB` custom resource named `mdb-rs`. This resource definition instructs the MongoDB Kubernetes Operator to configure a MongoDB replica set with 3 members, running version 8.0.10. MongoDB Search is supported only from MongoDB Enterprise Server version 8.0.10. It also defines CPU and memory resources for the `mongodb-enterprise-database` container, and sets up three users: + + +[code_snippets/0305_create_mongodb_database_resource.sh](code_snippets/0305_create_mongodb_database_resource.sh) +```yaml copy +{% include "code_snippets/0305_create_mongodb_database_resource.sh" %} +``` + +### 5. Wait for MongoDB Enterprise Resource to be Ready + +After applying the `MongoDB` custom resource, the operator begins deploying the MongoDB nodes (pods). This step uses `kubectl wait` to pause execution until the `mdb-rs` resource's status phase becomes `Running`, indicating that the MongoDB Enterprise replica set is operational. + +[code_snippets/0310_wait_for_database_resource.sh](code_snippets/0310_wait_for_database_resource.sh) +```shell copy +{% include "code_snippets/0310_wait_for_database_resource.sh" %} +``` + +### 6. Create MongoDB Users + +MongoDB requires authentication for secure access. This step creates three Kubernetes secrets: `mdb-admin-user-password`, `mdb-rs-search-sync-source-password`, and `mdb-user-password`. These secrets store the credentials for the MongoDB administrative user, the MongoDB Search service, and a dedicated user, respectively. These secrets will be mounted into the MongoDB pods. + +These secrets are then used to create the following users: +* `mdb-admin` - root user that restores the `sample_mflix` database from backup. +* `search-sync-source` - user that the MongoDB Search service is authenticating to the MongoDB Server as in order to manage and build indexes. +* `mdb-user` - a regular user that will execute search queries. + + +[code_snippets/0315_create_mongodb_users.sh](code_snippets/0315_create_mongodb_users.sh) +```shell copy +{% include "code_snippets/0315_create_mongodb_users.sh" %} +``` +Ensure these secrets and users are created in the same namespace where you deploy MongoDB Server and Search. + +### 7. Create MongoDB Search Resource + +Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdb-rs` to associate it with the MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. + +Note: Public Preview of MongoDB Search comes with some limitations, and it is not suitable for production use: +* Only one instance of the search node is supported (load balancing is not supported) + +[code_snippets/0320_create_mongodb_search_resource.sh](code_snippets/0320_create_mongodb_search_resource.sh) +```shell copy +{% include "code_snippets/0320_create_mongodb_search_resource.sh" %} +``` + +### 8. Wait for Search Resource to be Ready + +Similar to the MongoDB deployment, the Search deployment needs time to initialize. This step uses `kubectl wait` to pause until the `MongoDBSearch` resource `mdb-rs` reports a `Running` status in its `.status.phase` field, indicating that the search nodes are operational and integrated. + +[code_snippets/0325_wait_for_search_resource.sh](code_snippets/0325_wait_for_search_resource.sh) +```shell copy +{% include "code_snippets/0325_wait_for_search_resource.sh" %} +``` +This command polls the status of the `MongoDBSearch` resource `mdb-rs`. + +### 9. Verify MongoDB Enterprise Resource Status + +Double-check the status of your `MongoDB` resource to ensure it remains healthy and that the integration with the Search resource is reflected if applicable. + +[code_snippets/0330_wait_for_database_resource.sh](code_snippets/0330_wait_for_database_resource.sh) +```shell copy +{% include "code_snippets/0330_wait_for_database_resource.sh" %} +``` +This provides a final confirmation that the core database is operational. + +### 10. List Running Pods + +View all the running pods in your namespace. You should see pods for the MongoDB replica set members, the MongoDB Kubernetes Operator, and the MongoDB Search nodes. + +[code_snippets/0335_show_running_pods.sh](code_snippets/0335_show_running_pods.sh) +```shell copy +{% include "code_snippets/0335_show_running_pods.sh" %} +``` + +## Using MongoDB Search + +Now that your MongoDB Enterprise database with Search is deployed, you can start using its search capabilities. + +### 11. Deploy MongoDB Tools Pod + +To interact with your MongoDB deployment, this step deploys a utility pod named `mongodb-tools-pod`. This pod runs a MongoDB Enterprise Server image and is kept running with a `sleep infinity` command, allowing you to use `kubectl exec` to run MongoDB client tools like `mongosh` and `mongorestore` from within the Kubernetes cluster. Running steps in a pod inside the cluster simplifies connectivity to your MongoDB deployment without neeeding to expose the database externally (provided steps directly connect to the *.cluster.local hostnames). + +[code_snippets/0410_run_mongodb_tools_pod.sh](code_snippets/0410_run_mongodb_tools_pod.sh) +```shell copy +{% include "code_snippets/0410_run_mongodb_tools_pod.sh" %} +``` + +### 12. Import Sample Data + +To test the search functionality, this step imports the `sample_mflix.movies` collection. It downloads the sample dataset and uses `mongorestore` to load the data into the `sample_mflix` database in your MongoDB deployment, connecting as the admin user. + +[code_snippets/0420_import_movies_mflix_database.sh](code_snippets/0420_import_movies_mflix_database.sh) +```shell copy +{% include "code_snippets/0420_import_movies_mflix_database.sh" %} +``` +This command uses `mongorestore` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. + +### 13. Create Search Index + +Before performing search queries, create a search index. This step uses `kubectl exec` to run `mongosh` in the `mongodb-tools-pod`. It connects to the `sample_mflix` database as `search-user` and calls `db.movies.createSearchIndex()` to create a search index named "default" with dynamic mappings on the `movies` collection. Dynamic mapping automatically indexes all fields with supported types. MongoDB Search offers flexible index definitions, allowing for dynamic and static field mappings, various analyzer types (standard, language-specific, custom), and features like synonyms and faceted search. + +[code_snippets/0430_create_search_index.sh](code_snippets/0430_create_search_index.sh) +```shell copy +{% include "code_snippets/0430_create_search_index.sh" %} +``` + +### 14. Wait for Search Index to be Ready + +Creating a search index is an asynchronous operation. This script polls periodically the status by executing `db.movies.getSearchIndexes("default")`. + +[code_snippets/0440_wait_for_search_index_ready.sh](code_snippets/0440_wait_for_search_index_ready.sh) +```shell copy +{% include "code_snippets/0440_wait_for_search_index_ready.sh" %} +``` + +### 15. Execute a Search Query + +Once the search index is ready, execute search queries using the `$search` aggregation pipeline stage. MongoDB Search supports a query language, allowing for various types of queries such as text search, autocomplete, faceting, and more. You can combine `$search` with other aggregation stages to further refine and process your results. + +[code_snippets/0450_execute_search_query.sh](code_snippets/0450_execute_search_query.sh) +```shell copy +{% include "code_snippets/0450_execute_search_query.sh" %} +``` diff --git a/docs/search/enterprise/quick-start/code_snippets/0045_create_namespaces.sh b/docs/search/enterprise/quick-start/code_snippets/0045_create_namespaces.sh new file mode 100755 index 000000000..7d0899c63 --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/0045_create_namespaces.sh @@ -0,0 +1 @@ +kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" create namespace "${MDB_NAMESPACE}" diff --git a/docs/search/enterprise/quick-start/code_snippets/0046_create_image_pull_secrets.sh b/docs/search/enterprise/quick-start/code_snippets/0046_create_image_pull_secrets.sh new file mode 100755 index 000000000..270bdbe11 --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/0046_create_image_pull_secrets.sh @@ -0,0 +1,3 @@ +kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" \ + create secret generic "image-registries-secret" \ + --from-file=.dockerconfigjson="${HOME}/.docker/config.json" --type=kubernetes.io/dockerconfigjson diff --git a/docs/search/enterprise/quick-start/code_snippets/0050_configure_ops_manager_project.sh b/docs/search/enterprise/quick-start/code_snippets/0050_configure_ops_manager_project.sh new file mode 100644 index 000000000..9ab363540 --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/0050_configure_ops_manager_project.sh @@ -0,0 +1,5 @@ +if [[ "${ops_manager_version}" == "cloud_qa" && -n "${PROJECT_DIR}" ]]; then + pushd "${PROJECT_DIR}" + scripts/dev/configure_operator.sh + popd +fi diff --git a/docs/search/enterprise/quick-start/code_snippets/0100_install_operator.sh b/docs/search/enterprise/quick-start/code_snippets/0100_install_operator.sh new file mode 100755 index 000000000..36715a6a2 --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/0100_install_operator.sh @@ -0,0 +1,6 @@ +helm upgrade --install --debug --kube-context "${K8S_CLUSTER_0_CONTEXT_NAME}" \ + --create-namespace \ + --namespace="${MDB_NAMESPACE}" \ + mongodb-kubernetes \ + --set "${OPERATOR_ADDITIONAL_HELM_VALUES:-"dummy=value"}" \ + "${OPERATOR_HELM_CHART}" diff --git a/docs/search/enterprise/quick-start/code_snippets/0305_create_mongodb_database_resource.sh b/docs/search/enterprise/quick-start/code_snippets/0305_create_mongodb_database_resource.sh new file mode 100755 index 000000000..6639978f0 --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/0305_create_mongodb_database_resource.sh @@ -0,0 +1,36 @@ +kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - < /tmp/mdb_script.js +mongosh --quiet "mongodb://mdb-user:${MDB_USER_PASSWORD}@mdb-rs-0.mdb-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdb-rs" < /tmp/mdb_script.js +EOF +)" diff --git a/docs/search/enterprise/quick-start/code_snippets/090_helm_add_mogodb_repo.sh b/docs/search/enterprise/quick-start/code_snippets/090_helm_add_mogodb_repo.sh new file mode 100755 index 000000000..a348a3e0f --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/090_helm_add_mogodb_repo.sh @@ -0,0 +1,3 @@ +helm repo add mongodb https://mongodb.github.io/helm-charts +helm repo update mongodb +helm search repo mongodb/mongodb-kubernetes diff --git a/docs/search/enterprise/quick-start/code_snippets/9010_delete_namespace.sh b/docs/search/enterprise/quick-start/code_snippets/9010_delete_namespace.sh new file mode 100755 index 000000000..ed2d3046d --- /dev/null +++ b/docs/search/enterprise/quick-start/code_snippets/9010_delete_namespace.sh @@ -0,0 +1 @@ +kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" delete namespace "${MDB_NAMESPACE}" diff --git a/docs/search/enterprise/quick-start/env_variables.sh b/docs/search/enterprise/quick-start/env_variables.sh new file mode 100644 index 000000000..eb2fd1342 --- /dev/null +++ b/docs/search/enterprise/quick-start/env_variables.sh @@ -0,0 +1,22 @@ +# set it to the context name of the k8s cluster +export K8S_CLUSTER_0_CONTEXT_NAME="" + +# the following namespace will be created if not exists +export MDB_NAMESPACE="mongodb" + +# minimum required MongoDB version for running MongoDB Search is 8.0.10 +export MDB_VERSION="8.0.10" + +# root admin user for restoring the database from a sample backup +export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME" +# regular user performing search queries on sample mflix database +export MDB_USER_PASSWORD="mdb-user-password-CHANGE-ME" +# user for MongoDB Search to connect to the replica set to synchronise data from +export MDB_SEARCH_SYNC_USER_PASSWORD="search-sync-user-password-CHANGE-ME" + +export MDB_OPS_MANAGER_CONFIG_MAP_NAME="" +export MDB_OPS_MANAGER_CREDENTIALS_SECRET_NAME="" + +export OPERATOR_HELM_CHART="mongodb/mongodb-kubernetes" +# comma-separated key=value pairs for additional parameters passed to the helm-chart installing the operator +export OPERATOR_ADDITIONAL_HELM_VALUES="" diff --git a/docs/search/enterprise/quick-start/env_variables_e2e_prerelease.sh b/docs/search/enterprise/quick-start/env_variables_e2e_prerelease.sh new file mode 100644 index 000000000..b708d7786 --- /dev/null +++ b/docs/search/enterprise/quick-start/env_variables_e2e_prerelease.sh @@ -0,0 +1,6 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" + +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="${COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON}" + +export OPERATOR_ADDITIONAL_HELM_VALUES="" +export OPERATOR_HELM_CHART="${PROJECT_DIR}/helm_chart" diff --git a/docs/search/enterprise/quick-start/env_variables_e2e_private.sh b/docs/search/enterprise/quick-start/env_variables_e2e_private.sh new file mode 100644 index 000000000..13ff9800b --- /dev/null +++ b/docs/search/enterprise/quick-start/env_variables_e2e_private.sh @@ -0,0 +1,11 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" + +source "${PROJECT_DIR}/scripts/funcs/operator_deployment" +source "${PROJECT_DIR}/scripts/dev/contexts/e2e_mdb_kind_ubi_cloudqa" +OPERATOR_ADDITIONAL_HELM_VALUES="$(get_operator_helm_values | tr ' ' ',')" +export OPERATOR_ADDITIONAL_HELM_VALUES +export OPERATOR_HELM_CHART="${PROJECT_DIR}/helm_chart" + +export MDB_NAMESPACE="${NAMESPACE}" +export MDB_OPS_MANAGER_CONFIG_MAP_NAME="my-project" +export MDB_OPS_MANAGER_CREDENTIALS_SECRET_NAME="my-credentials" diff --git a/docs/search/enterprise/quick-start/env_variables_e2e_private_dev.sh b/docs/search/enterprise/quick-start/env_variables_e2e_private_dev.sh new file mode 100644 index 000000000..24df6655f --- /dev/null +++ b/docs/search/enterprise/quick-start/env_variables_e2e_private_dev.sh @@ -0,0 +1,36 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="kind-kind" + +# patch id from evergreen patch +version_id="688d3c049457710007a030a0" + +search_image_repo="268558157000.dkr.ecr.eu-west-1.amazonaws.com/mongot" +search_image_hash="fbd60fb055dd500058edcb45677ea85d19421f47" + +ecr="268558157000.dkr.ecr.us-east-1.amazonaws.com" +declare -a helm_values=( +"registry.imagePullSecrets=image-registries-secret" +"registry.operator=${ecr}/dev" +"registry.initOpsManager=${ecr}/dev" +"registry.initAppDb=${ecr}/dev" +"registry.initDatabase=${ecr}/dev" +"registry.agent=${ecr}/dev" +"registry.opsManager=quay.io/mongodb" +"registry.appDb=quay.io/mongodb" +"registry.database=${ecr}/dev" +"operator.version=${version_id}" +"initOpsManager.version=${version_id}" +"initAppDb.version=${version_id}" +"initDatabase.version=${version_id}" +"database.version=${version_id}" +"search.community.repo=${search_image_repo}" +"search.community.name=community" +"search.community.version=${search_image_hash}" +) + +SCRIPT_PATH="${BASH_SOURCE[0]}" +SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)" + +OPERATOR_ADDITIONAL_HELM_VALUES="$(echo -n "${helm_values[@]}" | tr ' ' ',')" +export OPERATOR_ADDITIONAL_HELM_VALUES +OPERATOR_HELM_CHART="$(realpath "${SCRIPT_DIR}/../../../../helm_chart")" +export OPERATOR_HELM_CHART diff --git a/docs/search/enterprise/quick-start/env_variables_e2e_public.sh b/docs/search/enterprise/quick-start/env_variables_e2e_public.sh new file mode 100644 index 000000000..8a835d9b7 --- /dev/null +++ b/docs/search/enterprise/quick-start/env_variables_e2e_public.sh @@ -0,0 +1,2 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="${COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON}" diff --git a/docs/search/enterprise/quick-start/output/0100_install_operator.out b/docs/search/enterprise/quick-start/output/0100_install_operator.out new file mode 100644 index 000000000..84ef0e38a --- /dev/null +++ b/docs/search/enterprise/quick-start/output/0100_install_operator.out @@ -0,0 +1,608 @@ +Release "mongodb-kubernetes" does not exist. Installing it now. +NAME: mongodb-kubernetes +LAST DEPLOYED: Fri Aug 1 22:48:48 2025 +NAMESPACE: mongodb-test +STATUS: deployed +REVISION: 1 +TEST SUITE: None +USER-SUPPLIED VALUES: +database: + version: 688cf772f2350700075c5909 +initAppDb: + version: 688cf772f2350700075c5909 +initDatabase: + version: 688cf772f2350700075c5909 +initOpsManager: + version: 688cf772f2350700075c5909 +operator: + version: 688cf772f2350700075c5909 +registry: + agent: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + appDb: quay.io/mongodb + database: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + imagePullSecrets: image-registries-secret2 + initAppDb: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + initDatabase: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + initOpsManager: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + operator: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + opsManager: quay.io/mongodb +search: + community: + name: community + repo: 268558157000.dkr.ecr.eu-west-1.amazonaws.com/mongot + version: fbd60fb055dd500058edcb45677ea85d19421f47 + +COMPUTED VALUES: +agent: + name: mongodb-agent-ubi + version: 108.0.2.8729-1 +community: + agent: + name: mongodb-agent-ubi + version: 108.0.2.8729-1 + mongodb: + imageType: ubi8 + name: mongodb-community-server + repo: quay.io/mongodb + name: mongodb-database + registry: + agent: quay.io/mongodb + resource: + members: 3 + name: mongodb-replica-set + tls: + caCertificateSecretRef: tls-ca-key-pair + certManager: + certDuration: 8760h + renewCertBefore: 720h + certificateKeySecretRef: tls-certificate + enabled: false + sampleX509User: false + useCertManager: true + useX509: false + version: 4.4.0 +database: + name: mongodb-kubernetes-database + version: 688cf772f2350700075c5909 +initAppDb: + name: mongodb-kubernetes-init-appdb + version: 688cf772f2350700075c5909 +initDatabase: + name: mongodb-kubernetes-init-database + version: 688cf772f2350700075c5909 +initOpsManager: + name: mongodb-kubernetes-init-ops-manager + version: 688cf772f2350700075c5909 +managedSecurityContext: false +mongodb: + appdbAssumeOldFormat: false + imageType: ubi8 + name: mongodb-enterprise-server + repo: quay.io/mongodb +multiCluster: + clusterClientTimeout: 10 + clusters: [] + kubeConfigSecretName: mongodb-enterprise-operator-multi-cluster-kubeconfig + performFailOver: true +operator: + additionalArguments: [] + affinity: {} + baseName: mongodb-kubernetes + createOperatorServiceAccount: true + createResourcesServiceAccountsAndRoles: true + deployment_name: mongodb-kubernetes-operator + enableClusterMongoDBRoles: true + enablePVCResize: true + env: prod + maxConcurrentReconciles: 1 + mdbDefaultArchitecture: non-static + name: mongodb-kubernetes-operator + nodeSelector: {} + operator_image_name: mongodb-kubernetes + replicas: 1 + resources: + limits: + cpu: 1100m + memory: 1Gi + requests: + cpu: 500m + memory: 200Mi + telemetry: + collection: + clusters: {} + deployments: {} + frequency: 1h + operators: {} + send: + frequency: 168h + tolerations: [] + vaultSecretBackend: + enabled: false + tlsSecretRef: "" + version: 688cf772f2350700075c5909 + watchedResources: + - mongodb + - opsmanagers + - mongodbusers + - mongodbcommunity + - mongodbsearch + webhook: + installClusterRole: true + registerConfiguration: true +opsManager: + name: mongodb-enterprise-ops-manager-ubi +readinessProbe: + name: mongodb-kubernetes-readinessprobe + version: 1.0.22 +registry: + agent: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + appDb: quay.io/mongodb + database: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + imagePullSecrets: image-registries-secret2 + initAppDb: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + initDatabase: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + initOpsManager: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + operator: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev + opsManager: quay.io/mongodb + pullPolicy: Always + readinessProbe: quay.io/mongodb + versionUpgradeHook: quay.io/mongodb +search: + community: + name: community + repo: 268558157000.dkr.ecr.eu-west-1.amazonaws.com/mongot + version: fbd60fb055dd500058edcb45677ea85d19421f47 +versionUpgradeHook: + name: mongodb-kubernetes-operator-version-upgrade-post-start-hook + version: 1.0.9 + +HOOKS: +MANIFEST: +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-appdb + namespace: mongodb-test +imagePullSecrets: + - name: image-registries-secret2 +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-database-pods + namespace: mongodb-test +imagePullSecrets: + - name: image-registries-secret2 +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-ops-manager + namespace: mongodb-test +imagePullSecrets: + - name: image-registries-secret2 +--- +# Source: mongodb-kubernetes/templates/operator-sa.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb-test +imagePullSecrets: + - name: image-registries-secret2 +--- +# Source: mongodb-kubernetes/templates/operator-roles-clustermongodbroles.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-test-cluster-mongodb-role +rules: + - apiGroups: + - mongodb.com + verbs: + - '*' + resources: + - clustermongodbroles +--- +# Source: mongodb-kubernetes/templates/operator-roles-telemetry.yaml +# Additional ClusterRole for clusterVersionDetection +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-cluster-telemetry +rules: + # Non-resource URL permissions + - nonResourceURLs: + - "/version" + verbs: + - get + # Cluster-scoped resource permissions + - apiGroups: + - '' + resources: + - namespaces + resourceNames: + - kube-system + verbs: + - get + - apiGroups: + - '' + resources: + - nodes + verbs: + - list +--- +# Source: mongodb-kubernetes/templates/operator-roles-webhook.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-webhook +rules: + - apiGroups: + - "admissionregistration.k8s.io" + resources: + - validatingwebhookconfigurations + verbs: + - get + - create + - update + - delete + - apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch + - create + - update + - delete +--- +# Source: mongodb-kubernetes/templates/operator-roles-clustermongodbroles.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-test-cluster-mongodb-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-kubernetes-operator-mongodb-test-cluster-mongodb-role +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/operator-roles-telemetry.yaml +# ClusterRoleBinding for clusterVersionDetection +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-test-cluster-telemetry-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-kubernetes-operator-cluster-telemetry +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/operator-roles-webhook.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-test-webhook-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-kubernetes-operator-mongodb-webhook +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-appdb + namespace: mongodb-test +rules: + - apiGroups: + - '' + resources: + - secrets + verbs: + - get + - apiGroups: + - '' + resources: + - pods + verbs: + - patch + - delete + - get +--- +# Source: mongodb-kubernetes/templates/operator-roles-base.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb-test +rules: + - apiGroups: + - '' + resources: + - services + verbs: + - get + - list + - watch + - create + - update + - delete + - apiGroups: + - '' + resources: + - secrets + - configmaps + verbs: + - get + - list + - create + - update + - delete + - watch + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - get + - list + - watch + - delete + - update + - apiGroups: + - '' + resources: + - pods + verbs: + - get + - list + - watch + - delete + - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' + - apiGroups: + - mongodb.com + verbs: + - '*' + resources: + - mongodb + - mongodb/finalizers + - mongodbusers + - mongodbusers/finalizers + - opsmanagers + - opsmanagers/finalizers + - mongodbmulticluster + - mongodbmulticluster/finalizers + - mongodbsearch + - mongodbsearch/finalizers + - mongodb/status + - mongodbusers/status + - opsmanagers/status + - mongodbmulticluster/status + - mongodbsearch/status +--- +# Source: mongodb-kubernetes/templates/operator-roles-pvc-resize.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-pvc-resize + namespace: mongodb-test +rules: + - apiGroups: + - '' + resources: + - persistentvolumeclaims + verbs: + - get + - delete + - list + - watch + - patch + - update +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-appdb + namespace: mongodb-test +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-kubernetes-appdb +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-appdb + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/operator-roles-base.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb-test +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-kubernetes-operator +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/operator-roles-pvc-resize.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-pvc-resize-binding + namespace: mongodb-test +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-kubernetes-operator-pvc-resize +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb-test +--- +# Source: mongodb-kubernetes/templates/operator.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb-test +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-kubernetes-operator + app.kubernetes.io/instance: mongodb-kubernetes-operator + template: + metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-kubernetes-operator + app.kubernetes.io/instance: mongodb-kubernetes-operator + spec: + serviceAccountName: mongodb-kubernetes-operator + securityContext: + runAsNonRoot: true + runAsUser: 2000 + imagePullSecrets: + - name: image-registries-secret2 + containers: + - name: mongodb-kubernetes-operator + image: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes:688cf772f2350700075c5909" + imagePullPolicy: Always + args: + - -watch-resource=mongodb + - -watch-resource=opsmanagers + - -watch-resource=mongodbusers + - -watch-resource=mongodbcommunity + - -watch-resource=mongodbsearch + - -watch-resource=clustermongodbroles + command: + - /usr/local/bin/mongodb-kubernetes-operator + resources: + limits: + cpu: 1100m + memory: 1Gi + requests: + cpu: 500m + memory: 200Mi + env: + - name: OPERATOR_ENV + value: prod + - name: MDB_DEFAULT_ARCHITECTURE + value: non-static + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: WATCH_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY + value: "1h" + - name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY + value: "168h" + - name: CLUSTER_CLIENT_TIMEOUT + value: "10" + - name: IMAGE_PULL_POLICY + value: Always + # Database + - name: MONGODB_ENTERPRISE_DATABASE_IMAGE + value: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-database + - name: INIT_DATABASE_IMAGE_REPOSITORY + value: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-database + - name: INIT_DATABASE_VERSION + value: 688cf772f2350700075c5909 + - name: DATABASE_VERSION + value: 688cf772f2350700075c5909 + # Ops Manager + - name: OPS_MANAGER_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi + - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY + value: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-ops-manager + - name: INIT_OPS_MANAGER_VERSION + value: 688cf772f2350700075c5909 + # AppDB + - name: INIT_APPDB_IMAGE_REPOSITORY + value: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-appdb + - name: INIT_APPDB_VERSION + value: 688cf772f2350700075c5909 + - name: OPS_MANAGER_IMAGE_PULL_POLICY + value: Always + - name: AGENT_IMAGE + value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent-ubi:108.0.2.8729-1" + - name: MDB_AGENT_IMAGE_REPOSITORY + value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent-ubi" + - name: MONGODB_IMAGE + value: mongodb-enterprise-server + - name: MONGODB_REPO_URL + value: quay.io/mongodb + - name: MDB_IMAGE_TYPE + value: ubi8 + - name: PERFORM_FAILOVER + value: 'true' + - name: IMAGE_PULL_SECRETS + value: image-registries-secret2 + - name: MDB_MAX_CONCURRENT_RECONCILES + value: "1" + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: mongodb-kubernetes-operator + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9" + - name: READINESS_PROBE_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22" + - name: MDB_COMMUNITY_IMAGE + value: "mongodb-community-server" + - name: MDB_COMMUNITY_REPO_URL + value: "quay.io/mongodb" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "ubi8" + # Community Env Vars End + - name: MDB_SEARCH_COMMUNITY_REPO_URL + value: "268558157000.dkr.ecr.eu-west-1.amazonaws.com/mongot" + - name: MDB_SEARCH_COMMUNITY_NAME + value: "community" + - name: MDB_SEARCH_COMMUNITY_VERSION + value: "fbd60fb055dd500058edcb45677ea85d19421f47" + diff --git a/docs/search/enterprise/quick-start/output/0335_show_running_pods.out b/docs/search/enterprise/quick-start/output/0335_show_running_pods.out new file mode 100644 index 000000000..0101cdfd1 --- /dev/null +++ b/docs/search/enterprise/quick-start/output/0335_show_running_pods.out @@ -0,0 +1,16 @@ + +MongoDB resource +NAME PHASE VERSION TYPE AGE +mdb-rs Running 8.0.10 ReplicaSet 7m25s + +MongoDBSearch resource +NAME PHASE AGE +mdb-rs Running 4m45s + +Pods running in cluster kind-e2e-operator +NAME READY STATUS RESTARTS AGE +mdb-rs-0 1/1 Running 0 7m21s +mdb-rs-1 1/1 Running 0 6m36s +mdb-rs-2 1/1 Running 0 6m11s +mdb-rs-search-0 1/1 Running 0 3m20s +mongodb-kubernetes-operator-765f667584-jxzlc 1/1 Running 0 7m27s diff --git a/docs/search/enterprise/quick-start/output/0440_wait_for_search_index_ready.out b/docs/search/enterprise/quick-start/output/0440_wait_for_search_index_ready.out new file mode 100644 index 000000000..b264580af --- /dev/null +++ b/docs/search/enterprise/quick-start/output/0440_wait_for_search_index_ready.out @@ -0,0 +1 @@ +Sleeping to wait for search indexes to be created diff --git a/docs/search/enterprise/quick-start/output/0450_execute_search_query.out b/docs/search/enterprise/quick-start/output/0450_execute_search_query.out new file mode 100644 index 000000000..f425a96d8 --- /dev/null +++ b/docs/search/enterprise/quick-start/output/0450_execute_search_query.out @@ -0,0 +1,22 @@ +mdb-rs [primary] test> switched to db sample_mflix +mdb-rs [primary] sample_mflix> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... [ + { + plot: 'A sports agent stages an unconventional recruitment strategy to get talented Indian cricket players to play Major League Baseball.', + genres: [ 'Biography', 'Drama', 'Sport' ], + title: 'Million Dollar Arm', + released: ISODate('2014-05-16T00:00:00.000Z') + }, + { + plot: 'A Taiwanese high school baseball team travels to Japan in 1931 to compete in a national tournament.', + genres: [ 'Biography', 'Drama', 'History' ], + title: 'Kano', + released: ISODate('2014-02-27T00:00:00.000Z') + }, + { + plot: "12-year-old Josh is a mixed race boy and a promising baseball player. He is abused by his mother's boyfriend Byrd, and neglected by his mother Debbie. He forges his own path in life when ...", + genres: [ 'Drama' ], + title: 'Calloused Hands', + released: ISODate('2013-03-03T00:00:00.000Z') + } +] +mdb-rs [primary] sample_mflix> \ No newline at end of file diff --git a/docs/search/enterprise/quick-start/output/090_helm_add_mogodb_repo.out b/docs/search/enterprise/quick-start/output/090_helm_add_mogodb_repo.out new file mode 100644 index 000000000..b1576c236 --- /dev/null +++ b/docs/search/enterprise/quick-start/output/090_helm_add_mogodb_repo.out @@ -0,0 +1,6 @@ +"mongodb" already exists with the same configuration, skipping +Hang tight while we grab the latest from your chart repositories... +...Successfully got an update from the "mongodb" chart repository +Update Complete. ⎈Happy Helming!⎈ +NAME CHART VERSION APP VERSION DESCRIPTION +mongodb/mongodb-kubernetes 1.2.0 MongoDB Controllers for Kubernetes translate th... diff --git a/docs/search/enterprise/quick-start/test.sh b/docs/search/enterprise/quick-start/test.sh new file mode 100755 index 000000000..2df98c99e --- /dev/null +++ b/docs/search/enterprise/quick-start/test.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -eou pipefail + +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/../../../../scripts/code_snippets/sample_test_runner.sh" + +cd "${script_dir}" + +prepare_snippets + +run 0045_create_namespaces.sh +run 0046_create_image_pull_secrets.sh +run 0050_configure_ops_manager_project.sh + +run_for_output 090_helm_add_mogodb_repo.sh +run_for_output 0100_install_operator.sh +run 0305_create_mongodb_database_resource.sh +run 0310_wait_for_database_resource.sh +run 0315_create_mongodb_users.sh +run 0320_create_mongodb_search_resource.sh +run 0325_wait_for_search_resource.sh +run 0330_wait_for_database_resource.sh +run_for_output 0335_show_running_pods.sh +run 0410_run_mongodb_tools_pod.sh +run 0420_import_movies_mflix_database.sh +run 0430_create_search_index.sh +run_for_output 0440_wait_for_search_index_ready.sh +run_for_output 0450_execute_search_query.sh +cd - diff --git a/scripts/code_snippets/kind_community_search_snippets_render_template.sh b/scripts/code_snippets/kind_search_snippets_render_template.sh similarity index 79% rename from scripts/code_snippets/kind_community_search_snippets_render_template.sh rename to scripts/code_snippets/kind_search_snippets_render_template.sh index f7c86d1f7..2d63e9046 100755 --- a/scripts/code_snippets/kind_community_search_snippets_render_template.sh +++ b/scripts/code_snippets/kind_search_snippets_render_template.sh @@ -3,5 +3,5 @@ set -eou pipefail source scripts/dev/set_env_context.sh -test_dir="docs/community-search/quick-start" +test_dir="$1" python scripts/code_snippets/render_template.py "${test_dir}/README.md.j2" "${test_dir}/README.md" diff --git a/scripts/code_snippets/task_kind_community_search_snippets_test.sh b/scripts/code_snippets/task_kind_search_community_snippets_test.sh similarity index 82% rename from scripts/code_snippets/task_kind_community_search_snippets_test.sh rename to scripts/code_snippets/task_kind_search_community_snippets_test.sh index 4f23a3e37..3d8df6e42 100755 --- a/scripts/code_snippets/task_kind_community_search_snippets_test.sh +++ b/scripts/code_snippets/task_kind_search_community_snippets_test.sh @@ -11,7 +11,7 @@ dump_logs() { } trap dump_logs EXIT -test_dir="./docs/community-search/quick-start" +test_dir="./docs/search/community/quick-start" source "${test_dir}/env_variables.sh" echo "Sourcing env variables for ${CODE_SNIPPETS_FLAVOR} flavor" @@ -19,4 +19,4 @@ echo "Sourcing env variables for ${CODE_SNIPPETS_FLAVOR} flavor" test -f "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" && source "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" ${test_dir}/test.sh -scripts/code_snippets/kind_community_search_snippets_render_template.sh +scripts/code_snippets/kind_search_snippets_render_template.sh ${test_dir} diff --git a/scripts/code_snippets/task_kind_search_enterprise_snippets_test.sh b/scripts/code_snippets/task_kind_search_enterprise_snippets_test.sh new file mode 100755 index 000000000..cf9399478 --- /dev/null +++ b/scripts/code_snippets/task_kind_search_enterprise_snippets_test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eou pipefail +source scripts/dev/set_env_context.sh + +dump_logs() { + source scripts/evergreen/e2e/dump_diagnostic_information.sh + if [[ "${SKIP_DUMP:-"false"}" != "true" ]]; then + dump_all_non_default_namespaces "$@" + fi +} +trap dump_logs EXIT + +test_dir="./docs/search/enterprise/quick-start" + +source "${test_dir}/env_variables.sh" +echo "Sourcing env variables for ${CODE_SNIPPETS_FLAVOR} flavor" +# shellcheck disable=SC1090 +test -f "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" && source "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" + +${test_dir}/test.sh +scripts/code_snippets/kind_search_snippets_render_template.sh ${test_dir} diff --git a/scripts/dev/contexts/private_kind_code_snippets b/scripts/dev/contexts/private_kind_code_snippets index 970f0dc3f..4f968896f 100644 --- a/scripts/dev/contexts/private_kind_code_snippets +++ b/scripts/dev/contexts/private_kind_code_snippets @@ -10,5 +10,7 @@ script_dir=$(dirname "${script_name}") source "${script_dir}/root-context" source "${script_dir}/e2e_mdb_community" -export NAMESPACE=mongodb +export NAMESPACE=mongodb-test export CODE_SNIPPETS_FLAVOR=e2e_private + +export ops_manager_version="cloud_qa"