From 57b98225d818262f37cefbd1f8bf4fd2172a9336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Thu, 8 May 2025 12:51:45 +0200 Subject: [PATCH 01/12] Search docs # Conflicts: # .evergreen-functions.yml # .evergreen.yml # scripts/evergreen/e2e/dump_diagnostic_information.sh # scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh --- .evergreen-functions.yml | 29 +- .evergreen-tasks.yml | 16 +- .evergreen.yml | 36 +- .gitignore | 3 + docs/community-search/quick-start/README.md | 445 ++++++++++++++ .../community-search/quick-start/README.md.j2 | 209 +++++++ .../code_snippets/0045_create_namespaces.sh | 1 + .../0046_create_image_pull_secrets.sh | 3 + .../code_snippets/0100_install_operator.sh | 6 + ...0_configure_community_search_pullsecret.sh | 25 + ...0210_verify_community_search_pullsecret.sh | 9 + ...5_create_mongodb_community_user_secrets.sh | 7 + .../0310_create_mongodb_community_resource.sh | 55 ++ .../0315_wait_for_community_resource.sh | 6 + .../0320_create_mongodb_search_resource.sh | 14 + .../0325_wait_for_search_resource.sh | 2 + .../0330_wait_for_community_resource.sh | 2 + .../code_snippets/0335_show_running_pods.sh | 6 + .../0410_run_mongodb_tools_pod.sh | 20 + .../0420_import_movies_mflix_database.sh | 9 + .../code_snippets/0430_create_search_index.sh | 6 + .../0440_wait_for_search_index_ready.sh | 20 + .../0450_execute_search_query.sh | 47 ++ .../code_snippets/090_helm_add_mogodb_repo.sh | 3 + .../code_snippets/9010_delete_namespace.sh | 1 + .../community_search_snippets_test.sh.run.log | 16 + .../quick-start/env_variables.sh | 16 + .../quick-start/env_variables_e2e_private.sh | 8 + .../output/0100_install_operator.out | 573 ++++++++++++++++++ ..._configure_community_search_pullsecret.out | 19 + ...210_verify_community_search_pullsecret.out | 2 + .../output/0335_show_running_pods.out | 16 + .../0440_wait_for_search_index_ready.out | 4 + .../output/0450_execute_search_query.out | 22 + .../output/090_helm_add_mogodb_repo.out | 5 + docs/community-search/quick-start/test.sh | 33 + ...mmunity_search_snippets_render_template.sh | 7 + scripts/code_snippets/render_template.py | 24 + scripts/code_snippets/sample_commit_output.sh | 1 + ...ke_multi_cluster_no_mesh_snippets_test.sh} | 0 ...> task_gke_multi_cluster_snippets_test.sh} | 0 ...ask_kind_community_search_snippets_test.sh | 22 + .../dev/contexts/private_kind_code_snippets | 13 + .../e2e/dump_diagnostic_information.sh | 33 + ...gnostic_information_from_all_namespaces.sh | 12 + 45 files changed, 1783 insertions(+), 23 deletions(-) create mode 100644 docs/community-search/quick-start/README.md create mode 100644 docs/community-search/quick-start/README.md.j2 create mode 100755 docs/community-search/quick-start/code_snippets/0045_create_namespaces.sh create mode 100755 docs/community-search/quick-start/code_snippets/0046_create_image_pull_secrets.sh create mode 100644 docs/community-search/quick-start/code_snippets/0100_install_operator.sh create mode 100644 docs/community-search/quick-start/code_snippets/0200_configure_community_search_pullsecret.sh create mode 100644 docs/community-search/quick-start/code_snippets/0210_verify_community_search_pullsecret.sh create mode 100644 docs/community-search/quick-start/code_snippets/0305_create_mongodb_community_user_secrets.sh create mode 100644 docs/community-search/quick-start/code_snippets/0310_create_mongodb_community_resource.sh create mode 100644 docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh create mode 100644 docs/community-search/quick-start/code_snippets/0320_create_mongodb_search_resource.sh create mode 100644 docs/community-search/quick-start/code_snippets/0325_wait_for_search_resource.sh create mode 100644 docs/community-search/quick-start/code_snippets/0330_wait_for_community_resource.sh create mode 100644 docs/community-search/quick-start/code_snippets/0335_show_running_pods.sh create mode 100644 docs/community-search/quick-start/code_snippets/0410_run_mongodb_tools_pod.sh create mode 100644 docs/community-search/quick-start/code_snippets/0420_import_movies_mflix_database.sh create mode 100644 docs/community-search/quick-start/code_snippets/0430_create_search_index.sh create mode 100644 docs/community-search/quick-start/code_snippets/0440_wait_for_search_index_ready.sh create mode 100644 docs/community-search/quick-start/code_snippets/0450_execute_search_query.sh create mode 100644 docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh create mode 100644 docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh create mode 100644 docs/community-search/quick-start/community_search_snippets_test.sh.run.log create mode 100644 docs/community-search/quick-start/env_variables.sh create mode 100644 docs/community-search/quick-start/env_variables_e2e_private.sh create mode 100644 docs/community-search/quick-start/output/0100_install_operator.out create mode 100644 docs/community-search/quick-start/output/0200_configure_community_search_pullsecret.out create mode 100644 docs/community-search/quick-start/output/0210_verify_community_search_pullsecret.out create mode 100644 docs/community-search/quick-start/output/0335_show_running_pods.out create mode 100644 docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out create mode 100644 docs/community-search/quick-start/output/0450_execute_search_query.out create mode 100644 docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out create mode 100755 docs/community-search/quick-start/test.sh create mode 100755 scripts/code_snippets/kind_community_search_snippets_render_template.sh create mode 100644 scripts/code_snippets/render_template.py rename scripts/code_snippets/{gke_multi_cluster_no_mesh_test.sh => task_gke_multi_cluster_no_mesh_snippets_test.sh} (100%) rename scripts/code_snippets/{gke_multi_cluster_test.sh => task_gke_multi_cluster_snippets_test.sh} (100%) create mode 100755 scripts/code_snippets/task_kind_community_search_snippets_test.sh create mode 100644 scripts/dev/contexts/private_kind_code_snippets create mode 100755 scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh diff --git a/.evergreen-functions.yml b/.evergreen-functions.yml index e8a4f742c..d0dc2cbdf 100644 --- a/.evergreen-functions.yml +++ b/.evergreen-functions.yml @@ -331,6 +331,14 @@ functions: source .generated/context.export.env scripts/evergreen/e2e/setup_cloud_qa.py delete + dump_diagnostic_information_from_all_namespaces: + - command: subprocess.exec + params: + working_dir: src/github.com/mongodb/mongodb-kubernetes + add_to_path: + - bin + binary: scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh + ### Publish and release image ### # Tags and pushes an image into an external Docker registry. The source image @@ -731,25 +739,12 @@ functions: params: include_expansions_in_env: - GH_TOKEN + - code_snippets_commit_output working_dir: src/github.com/mongodb/mongodb-kubernetes binary: scripts/code_snippets/sample_commit_output.sh - gke_multi_cluster_snippets: - - *switch_context - - command: shell.exec - params: - shell: bash - working_dir: src/github.com/mongodb/mongodb-kubernetes - include_expansions_in_env: - - version_id - - code_snippets_teardown - - code_snippets_reset - - task_name - script: | - ./scripts/code_snippets/gke_multi_cluster_test.sh - - - gke_multi_cluster_no_mesh_snippets: + # it executes a script by convention: ./scripts/code_snippets/${task_name}_test.sh + test_code_snippets: - *switch_context - command: shell.exec params: @@ -761,4 +756,4 @@ functions: - code_snippets_reset - task_name script: | - ./scripts/code_snippets/gke_multi_cluster_no_mesh_test.sh + ./scripts/code_snippets/${task_name}_test.sh diff --git a/.evergreen-tasks.yml b/.evergreen-tasks.yml index ef9ac407f..ee28ab74e 100644 --- a/.evergreen-tasks.yml +++ b/.evergreen-tasks.yml @@ -70,16 +70,24 @@ tasks: vars: image_name: ops-manager - - name: gke_multi_cluster_snippets +# Code snippets tasks +# Each task is selected by convention by running scripts/code_snippets/${task_name}_test.sh + - name: task_gke_multi_cluster_snippets tags: [ "code_snippets" ] commands: - - func: gke_multi_cluster_snippets + - func: test_code_snippets - func: sample_commit_output - - name: gke_multi_cluster_no_mesh_snippets + - name: task_gke_multi_cluster_no_mesh_snippets tags: [ "code_snippets" ] commands: - - func: gke_multi_cluster_no_mesh_snippets + - func: test_code_snippets + - func: sample_commit_output + + - name: task_kind_community_search_snippets + tags: [ "code_snippets", "patch-run" ] + commands: + - func: test_code_snippets - func: sample_commit_output ## Below are only e2e runs for .evergreen.yml ## diff --git a/.evergreen.yml b/.evergreen.yml index 5a9d048e4..78e2fbf80 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -86,6 +86,7 @@ variables: - func: build_multi_cluster_binary - &setup_and_teardown_group_gke_code_snippets + setup_task_can_fail_task: true setup_group: - func: clone - func: setup_gcloud_cli @@ -95,6 +96,18 @@ variables: teardown_group: - func: upload_code_snippets_logs + - &setup_and_teardown_group_kind_code_snippets + setup_task_can_fail_task: true + setup_group: + - func: clone + - func: cleanup_exec_environment + - func: download_kube_tools + - func: configure_docker_auth + - func: setup_kubernetes_environment + teardown_task: + - func: upload_e2e_logs + - func: upload_code_snippets_logs + - &setup_and_teardown_task_cloudqa setup_task_can_fail_task: true setup_task: @@ -183,6 +196,10 @@ parameters: value: "false" description: set this to true if you would like to delete the resources created in the code snippet tests, but keep the clusters + - key: code_snippets_commit_output + value: "false" + description: set this to true if you would like the pipeline to automatically push a branch with updated snippets outputs + # Triggered manually or by PCT. patch_aliases: @@ -608,8 +625,14 @@ task_groups: <<: *setup_and_teardown_group_gke_code_snippets max_hosts: -1 tasks: - - gke_multi_cluster_snippets - - gke_multi_cluster_no_mesh_snippets + - task_gke_multi_cluster_snippets + - task_gke_multi_cluster_no_mesh_snippets + + - name: kind_code_snippets_task_group + <<: *setup_and_teardown_group_kind_code_snippets + max_hosts: -1 + tasks: + - task_kind_community_search_snippets # Task group for deploying mongodbcommunity resources and testing the (former) MCO - name: e2e_mdb_community_task_group @@ -1837,6 +1860,15 @@ buildvariants: tasks: - name: gke_code_snippets_task_group + - name: private_kind_code_snippets + display_name: private_kind_code_snippets + allowed_requesters: ["patch"] + run_on: + - ubuntu2204-large + <<: *base_om8_dependency + tasks: + - name: kind_code_snippets_task_group + ### Build variants for manual patch only - name: publish_om60_images diff --git a/.gitignore b/.gitignore index 503581786..c5ca572c5 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,6 @@ docker/mongodb-kubernetes-tests/.test_identifiers* logs-debug/ /ssdlc-report/* .gocache/ + +docs/**/log/* +docs/**/test.sh.run.log diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md new file mode 100644 index 000000000..ae5641271 --- /dev/null +++ b/docs/community-search/quick-start/README.md @@ -0,0 +1,445 @@ +# MongoDB Community Search on Kubernetes - Quick Start + +This guide provides instructions for deploying MongoDB Community 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). +- **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. +- **jq**: A command-line JSON processor, used for parsing JSON output from kubectl commands. +- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Ensure you are using at least version 5. + +## Setup Steps + +The following steps guide you through deploying MongoDB Community 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="" + +# At the private preview stage the community search image is accessible only from a private repository. +# Please contact MongoDB Support to get access. +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="<.dockerconfigjson>" + +# the following namespace will be created if not exists +export MDB_NAMESPACE="mongodb" + +export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME" +export MDB_SEARCH_USER_PASSWORD="search-user-password-CHANGE-ME" + +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 +if [[ "${OPERATOR_HELM_CHART}" != "helm_chart" ]]; then helm search repo "${OPERATOR_HELM_CHART}"; fi; +``` +After adding the repository, update your local Helm chart repository cache: +```shell +helm repo update +``` + +### 3. Install MongoDB Kubernetes Operator + +Next, install the MongoDB Kubernetes Operator from the Helm repository you just added. The Operator will watch for MongoDBCommunity 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) and names the release `community-operator`. + +### 4. Configure Pull Secret for MongoDB Community Search + +To use MongoDB Search, your Kubernetes cluster needs to pull the necessary container images. This step creates a Kubernetes secret named `community-private-preview-pullsecret`. This secret stores the credentials required to access the image repository for MongoDB Search. The script then patches the `mongodb-kubernetes-database-pods` service account to include this pull secret, allowing pods managed by this service account to pull the required images. + +[code_snippets/0200_configure_community_search_pullsecret.sh](code_snippets/0200_configure_community_search_pullsecret.sh) +```shell copy +kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - < /tmp/mdb_script.js +mongosh --quiet "mongodb://search-user:${MDB_SEARCH_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdbc-rs" < /tmp/mdb_script.js +EOF +)" +``` \ No newline at end of file diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 new file mode 100644 index 000000000..adb3a9c7d --- /dev/null +++ b/docs/community-search/quick-start/README.md.j2 @@ -0,0 +1,209 @@ +# MongoDB Community Search on Kubernetes - Quick Start + +This guide provides instructions for deploying MongoDB Community 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). +- **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. +- **jq**: A command-line JSON processor, used for parsing JSON output from kubectl commands. +- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Ensure you are using at least version 5. + +## Setup Steps + +The following steps guide you through deploying MongoDB Community 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" %} +``` +After adding the repository, update your local Helm chart repository cache: +```shell +helm repo update +``` + +### 3. Install MongoDB Kubernetes Operator + +Next, install the MongoDB Kubernetes Operator from the Helm repository you just added. The Operator will watch for MongoDBCommunity 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) and names the release `community-operator`. + +### 4. Configure Pull Secret for MongoDB Community Search + +To use MongoDB Search, your Kubernetes cluster needs to pull the necessary container images. This step creates a Kubernetes secret named `community-private-preview-pullsecret`. This secret stores the credentials required to access the image repository for MongoDB Search. The script then patches the `mongodb-kubernetes-database-pods` service account to include this pull secret, allowing pods managed by this service account to pull the required images. + +[code_snippets/0200_configure_community_search_pullsecret.sh](code_snippets/0200_configure_community_search_pullsecret.sh) +```shell copy +{% include "code_snippets/0200_configure_community_search_pullsecret.sh" %} +``` +This script creates a `docker-registry` secret in your Kubernetes namespace and associates it with the service account used for MongoDB pods. + +### 5. Verify Pull Secret Configuration + +Confirm that the `community-private-preview-pullsecret` has been successfully added to the `mongodb-kubernetes-database-pods` service account. This ensures that Kubernetes can authenticate with the container registry when pulling images for MongoDB Search pods. + +[code_snippets/0210_verify_community_search_pullsecret.sh](code_snippets/0210_verify_community_search_pullsecret.sh) +```shell copy +{% include "code_snippets/0210_verify_community_search_pullsecret.sh" %} +``` +This command checks the `mongodb-kubernetes-database-pods` service account to confirm the presence of `community-private-preview-pullsecret`. + +## Creating a MongoDB Community Search Deployment + +With the prerequisites and initial setup complete, you can now deploy MongoDB Community Edition and enable Search. + +### 6. Create MongoDB User Secrets + +MongoDB requires authentication for secure access. This step creates two Kubernetes secrets: `admin-user-password` and `search-user-password`. These secrets store the credentials for the MongoDB administrative user and a dedicated search user, respectively. These secrets will be mounted into the MongoDB pods. + +[code_snippets/0305_create_mongodb_community_user_secrets.sh](code_snippets/0305_create_mongodb_community_user_secrets.sh) +```shell copy +{% include "code_snippets/0305_create_mongodb_community_user_secrets.sh" %} +``` +Ensure these secrets are created in the same namespace where you plan to deploy MongoDB. + +### 7. Create MongoDB Community Resource + +Now, deploy MongoDB Community by creating a `MongoDBCommunity` custom resource named `mdbc-rs`. This resource definition instructs the MongoDB Kubernetes Operator to configure a MongoDB replica set with 3 members, running version 8.0.6. MongoDB Community Search is supported only from MongoDB Community Server version 8.0. It also defines CPU and memory resources for the `mongod` and `mongodb-agent` containers, and sets up two users (`admin-user` and `search-user`) with their respective roles and password secrets. User `search-user` will be used to restore, connect and perform search queries on the `sample_mflix` database. + +[code_snippets/0310_create_mongodb_community_resource.sh](code_snippets/0310_create_mongodb_community_resource.sh) +```yaml copy +{% include "code_snippets/0310_create_mongodb_community_resource.sh" %} +``` + +### 8. Wait for MongoDB Community Resource to be Ready + +After applying the `MongoDBCommunity` custom resource, the operator begins deploying the MongoDB nodes (pods). This step uses `kubectl wait` to pause execution until the `mdbc-rs` resource's status phase becomes `Running`, indicating that the MongoDB Community replica set is operational. + +[code_snippets/0315_wait_for_community_resource.sh](code_snippets/0315_wait_for_community_resource.sh) +```shell copy +{% include "code_snippets/0315_wait_for_community_resource.sh" %} +``` + +### 9. Create MongoDB Search Resource + +Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdbc-rs` to associate it with the MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. + +Note: Private preview of MongoDB Community Search comes with some limitations, and it is not suitable for production use: +* TLS cannot be enabled in MongoDB Community deployment (MongoD communicates with MongoT with plain text). +* Only one node of search node is supported (load balancing 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" %} +``` + +The `MongoDBSearch.spec` fields are supported: +* `spec.source.mongodbResourceRef.name` - omitted in the example as the MongoDBSearch CR has the same name as MongoDBCommunity CR allowing to integrate both using naming convention. While keeping the same name is recommended (you cannot have more than one MongoDBSearch resources referencing the same MongoDBCommunity resource - it's 1:1 relationship) it's not enforced. The name can be different, but then you must explicitly point to the MongoDBCommunity you would like to enable search in. Note that you enable search capabilities by deploying search component (with MongoDBSearch CR) and nothing is necessary to define in MongoDBCommunity CR to configure it for search - it will be configured automatically by recognising there is related MongoDBSearch pointing to it. +* `spec.version`: Version of mongodb-community-search. By default, the operator chooses the MongoDB Search version automatically, but it is possible to specify it explicitly. Currently, the default value is `1.47.0`. +* `spec.statefulSet`: Optional statefulset overrides, which are applied last to the mongot's statefulset. It is possible to adjust any statefulset configuration that was create by the operator (the overrides are applied last). The type of the field is [apps/v1/StatefulSet](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#statefulset-v1-apps) and both `spec.statefulSet.spec` and `spec.statefulSet.metadata` fields are supported. +* `spec.persistence.single`: optional storage configuration for MongoDB Search persistence volume containing storing search indexes. See [here](https://www.mongodb.com/docs/kubernetes/current/reference/k8s-operator-specification/#mongodb-setting-spec.podSpec.persistence.single) for more information about storage settings. MongoDBSearch reuses the same persistence type as in other custom resources (e.g. `MongoDB`), but supports only `single` persistence field. If not set, the operator sets `spec.persistence.single.storage = 10G`. +* `spec.resourceRequirements` - resource requests and limits for mongodb-search container. It's recommended to use this field to customize resource allocations instead of overriding it via `spec.statefulSet` overrides. If not set, the operator sets the following values (no limits, only requests): +* ```yaml +requests: + cpu: 2 + memory: 2G +``` + +### 10. 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 `mdbc-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 `mdbc-rs`. + +### 11. Verify MongoDB Community Resource Status + +Double-check the status of your `MongoDBCommunity` resource to ensure it remains healthy and that the integration with the Search resource is reflected if applicable. + +[code_snippets/0330_wait_for_community_resource.sh](code_snippets/0330_wait_for_community_resource.sh) +```shell copy +{% include "code_snippets/0330_wait_for_community_resource.sh" %} +``` +This provides a final confirmation that the core database is operational. + +### 12. 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 Community database with Search is deployed, you can start using its search capabilities. + +### 13. 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 Community 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 mongodb 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" %} +``` + +### 14. 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 `search-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 `mongoimport` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. + +### 15. 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" %} +``` + +### 16. 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" %} +``` + +### 17. 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/community-search/quick-start/code_snippets/0045_create_namespaces.sh b/docs/community-search/quick-start/code_snippets/0045_create_namespaces.sh new file mode 100755 index 000000000..7d0899c63 --- /dev/null +++ b/docs/community-search/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/community-search/quick-start/code_snippets/0046_create_image_pull_secrets.sh b/docs/community-search/quick-start/code_snippets/0046_create_image_pull_secrets.sh new file mode 100755 index 000000000..270bdbe11 --- /dev/null +++ b/docs/community-search/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/community-search/quick-start/code_snippets/0100_install_operator.sh b/docs/community-search/quick-start/code_snippets/0100_install_operator.sh new file mode 100644 index 000000000..36715a6a2 --- /dev/null +++ b/docs/community-search/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/community-search/quick-start/code_snippets/0200_configure_community_search_pullsecret.sh b/docs/community-search/quick-start/code_snippets/0200_configure_community_search_pullsecret.sh new file mode 100644 index 000000000..59310c81f --- /dev/null +++ b/docs/community-search/quick-start/code_snippets/0200_configure_community_search_pullsecret.sh @@ -0,0 +1,25 @@ +kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - < /tmp/mdb_script.js +mongosh --quiet "mongodb://search-user:${MDB_SEARCH_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdbc-rs" < /tmp/mdb_script.js +EOF +)" diff --git a/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh b/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh new file mode 100644 index 000000000..8b19942ad --- /dev/null +++ b/docs/community-search/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 +if [[ "${OPERATOR_HELM_CHART}" != "helm_chart" ]]; then helm search repo "${OPERATOR_HELM_CHART}"; fi; diff --git a/docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh b/docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh new file mode 100644 index 000000000..96db9a4b6 --- /dev/null +++ b/docs/community-search/quick-start/code_snippets/9010_delete_namespace.sh @@ -0,0 +1 @@ +kubectl --context diff --git a/docs/community-search/quick-start/community_search_snippets_test.sh.run.log b/docs/community-search/quick-start/community_search_snippets_test.sh.run.log new file mode 100644 index 000000000..643009e51 --- /dev/null +++ b/docs/community-search/quick-start/community_search_snippets_test.sh.run.log @@ -0,0 +1,16 @@ +090_helm_add_mogodb_repo +0100_install_operator +0200_configure_community_search_pullsecret +0210_verify_community_search_pullsecret +0305_create_mongodb_community_user_secrets +0310_create_mongodb_community_resource +0315_wait_for_community_resource +0320_create_mongodb_search_resource +0325_wait_for_search_resource +0330_wait_for_community_resource +0335_show_running_pods +0410_run_mongodb_tools_pod +0420_import_movies_mflix_database +0430_create_search_index +0440_wait_for_search_index_ready +0450_execute_search_query diff --git a/docs/community-search/quick-start/env_variables.sh b/docs/community-search/quick-start/env_variables.sh new file mode 100644 index 000000000..0d0a98a5f --- /dev/null +++ b/docs/community-search/quick-start/env_variables.sh @@ -0,0 +1,16 @@ +# set it to the context name of the k8s cluster +export K8S_CLUSTER_0_CONTEXT_NAME="" + +# At the private preview stage the community search image is accessible only from a private repository. +# Please contact MongoDB Support to get access. +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="<.dockerconfigjson>" + +# the following namespace will be created if not exists +export MDB_NAMESPACE="mongodb" + +export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME" +export MDB_SEARCH_USER_PASSWORD="search-user-password-CHANGE-ME" + +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/community-search/quick-start/env_variables_e2e_private.sh b/docs/community-search/quick-start/env_variables_e2e_private.sh new file mode 100644 index 000000000..7996f92a9 --- /dev/null +++ b/docs/community-search/quick-start/env_variables_e2e_private.sh @@ -0,0 +1,8 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" + +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="${COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON}" + +source scripts/funcs/operator_deployment +OPERATOR_ADDITIONAL_HELM_VALUES="$(get_operator_helm_values | tr ' ' ',')" +export OPERATOR_ADDITIONAL_HELM_VALUES +export OPERATOR_HELM_CHART="${PROJECT_DIR}/helm_chart" diff --git a/docs/community-search/quick-start/output/0100_install_operator.out b/docs/community-search/quick-start/output/0100_install_operator.out new file mode 100644 index 000000000..22d3c51cd --- /dev/null +++ b/docs/community-search/quick-start/output/0100_install_operator.out @@ -0,0 +1,573 @@ +Release "mongodb-kubernetes" does not exist. Installing it now. +NAME: mongodb-kubernetes +LAST DEPLOYED: Sat May 10 11:44:37 2025 +NAMESPACE: mongodb +STATUS: deployed +REVISION: 1 +TEST SUITE: None +USER-SUPPLIED VALUES: +agent: + version: 108.0.2.8729-1 +database: + name: mongodb-kubernetes-database + version: 681da7cd38e00c0007d35c5d +initAppDb: + version: 681da7cd38e00c0007d35c5d +initDatabase: + version: 681da7cd38e00c0007d35c5d +initOpsManager: + version: 681da7cd38e00c0007d35c5d +managedSecurityContext: false +mongodb: + imageType: ubi9 + name: mongodb-enterprise-server +operator: + enablePVCResize: true + maxConcurrentReconciles: 10 + mdbDefaultArchitecture: non-static + telemetry: + collection: + frequency: 1m + send: + enabled: false + version: 681da7cd38e00c0007d35c5d +opsManager: + name: mongodb-enterprise-ops-manager-ubi +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-secret + 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 + +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: 681da7cd38e00c0007d35c5d +initAppDb: + name: mongodb-kubernetes-init-appdb + version: 681da7cd38e00c0007d35c5d +initDatabase: + name: mongodb-kubernetes-init-database + version: 681da7cd38e00c0007d35c5d +initOpsManager: + name: mongodb-kubernetes-init-ops-manager + version: 681da7cd38e00c0007d35c5d +managedSecurityContext: false +mongodb: + appdbAssumeOldFormat: false + imageType: ubi9 + 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 + enablePVCResize: true + env: prod + maxConcurrentReconciles: 10 + 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: 1m + operators: {} + send: + enabled: false + frequency: 168h + tolerations: [] + vaultSecretBackend: + enabled: false + tlsSecretRef: "" + version: 681da7cd38e00c0007d35c5d + 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-secret + 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: watchdiff + repo: quay.io/lsierant + version: mongot-community-bd5ac +subresourceEnabled: true +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 +imagePullSecrets: + - name: image-registries-secret +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-database-pods + namespace: mongodb +imagePullSecrets: + - name: image-registries-secret +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-ops-manager + namespace: mongodb +imagePullSecrets: + - name: image-registries-secret +--- +# Source: mongodb-kubernetes/templates/operator-sa.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb +imagePullSecrets: + - name: image-registries-secret +--- +# Source: mongodb-kubernetes/templates/operator-roles.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.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.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-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 +--- +# Source: mongodb-kubernetes/templates/operator-roles.yaml +# ClusterRoleBinding for clusterVersionDetection +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator-mongodb-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 +--- +# Source: mongodb-kubernetes/templates/database-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-appdb + namespace: mongodb +rules: + - apiGroups: + - '' + resources: + - secrets + verbs: + - get + - apiGroups: + - '' + resources: + - pods + verbs: + - patch + - delete + - get +--- +# Source: mongodb-kubernetes/templates/operator-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb +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 + + - 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 +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-kubernetes-appdb +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-appdb + namespace: mongodb +--- +# Source: mongodb-kubernetes/templates/operator-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-kubernetes-operator +subjects: + - kind: ServiceAccount + name: mongodb-kubernetes-operator + namespace: mongodb +--- +# Source: mongodb-kubernetes/templates/operator.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongodb-kubernetes-operator + namespace: mongodb +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-secret + containers: + - name: mongodb-kubernetes-operator + image: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes:681da7cd38e00c0007d35c5d" + imagePullPolicy: Always + args: + - -watch-resource=mongodb + - -watch-resource=opsmanagers + - -watch-resource=mongodbusers + - -watch-resource=mongodbcommunity + - -watch-resource=mongodbsearch + 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: "1m" + - name: MDB_OPERATOR_TELEMETRY_SEND_ENABLED + value: "false" + - 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: 681da7cd38e00c0007d35c5d + - name: DATABASE_VERSION + value: 681da7cd38e00c0007d35c5d + # 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: 681da7cd38e00c0007d35c5d + # 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: 681da7cd38e00c0007d35c5d + - 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: ubi9 + - name: PERFORM_FAILOVER + value: 'true' + - name: IMAGE_PULL_SECRETS + value: image-registries-secret + - name: MDB_MAX_CONCURRENT_RECONCILES + value: "10" + - 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: "quay.io/lsierant" + - name: MDB_SEARCH_COMMUNITY_NAME + value: "watchdiff" + - name: MDB_SEARCH_COMMUNITY_VERSION + value: "mongot-community-bd5ac" + diff --git a/docs/community-search/quick-start/output/0200_configure_community_search_pullsecret.out b/docs/community-search/quick-start/output/0200_configure_community_search_pullsecret.out new file mode 100644 index 000000000..24f53fca8 --- /dev/null +++ b/docs/community-search/quick-start/output/0200_configure_community_search_pullsecret.out @@ -0,0 +1,19 @@ +secret/community-private-preview-pullsecret created +serviceaccount/mongodb-kubernetes-database-pods patched +ServiceAccount mongodb-kubernetes-database-pods has been patched: +apiVersion: v1 +imagePullSecrets: +- name: image-registries-secret +- name: community-private-preview-pullsecret +kind: ServiceAccount +metadata: + annotations: + meta.helm.sh/release-name: mongodb-kubernetes + meta.helm.sh/release-namespace: mongodb + creationTimestamp: "2025-05-10T09:44:40Z" + labels: + app.kubernetes.io/managed-by: Helm + name: mongodb-kubernetes-database-pods + namespace: mongodb + resourceVersion: "18484" + uid: 650e5b87-13a6-4dbf-91ce-43eb393ca863 diff --git a/docs/community-search/quick-start/output/0210_verify_community_search_pullsecret.out b/docs/community-search/quick-start/output/0210_verify_community_search_pullsecret.out new file mode 100644 index 000000000..49a524b01 --- /dev/null +++ b/docs/community-search/quick-start/output/0210_verify_community_search_pullsecret.out @@ -0,0 +1,2 @@ +Verifying mongodb-kubernetes-database-pods contains proper pull secret +{"name":"image-registries-secret"} {"name":"community-private-preview-pullsecret"} diff --git a/docs/community-search/quick-start/output/0335_show_running_pods.out b/docs/community-search/quick-start/output/0335_show_running_pods.out new file mode 100644 index 000000000..e25c2b7ee --- /dev/null +++ b/docs/community-search/quick-start/output/0335_show_running_pods.out @@ -0,0 +1,16 @@ + +MongoDBCommunity resource +NAME PHASE VERSION +mdbc-rs Running 8.0.6 + +MongoDBSearch resource +NAME PHASE AGE +mdbc-rs Running 5m32s + +Pods running in cluster kind-kind +NAME READY STATUS RESTARTS AGE +mdbc-rs-0 2/2 Running 1 (41s ago) 7m50s +mdbc-rs-1 2/2 Running 1 (3m18s ago) 7m2s +mdbc-rs-2 2/2 Running 1 (2m ago) 6m14s +mdbc-rs-search-0 1/1 Running 0 5m33s +mongodb-kubernetes-operator-7bbc7fffd5-8cjl8 1/1 Running 0 7m55s diff --git a/docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out b/docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out new file mode 100644 index 000000000..17d0d593b --- /dev/null +++ b/docs/community-search/quick-start/output/0440_wait_for_search_index_ready.out @@ -0,0 +1,4 @@ +Search index is not ready yet: status=BUILDING +Search index is not ready yet: status=BUILDING +Search index is not ready yet: status=BUILDING +Search index is ready. diff --git a/docs/community-search/quick-start/output/0450_execute_search_query.out b/docs/community-search/quick-start/output/0450_execute_search_query.out new file mode 100644 index 000000000..6d4329fb2 --- /dev/null +++ b/docs/community-search/quick-start/output/0450_execute_search_query.out @@ -0,0 +1,22 @@ +mdbc-rs [primary] test> switched to db sample_mflix +mdbc-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') + } +] +mdbc-rs [primary] sample_mflix> \ No newline at end of file diff --git a/docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out b/docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out new file mode 100644 index 000000000..926e69d06 --- /dev/null +++ b/docs/community-search/quick-start/output/090_helm_add_mogodb_repo.out @@ -0,0 +1,5 @@ +"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!⎈ +No results found diff --git a/docs/community-search/quick-start/test.sh b/docs/community-search/quick-start/test.sh new file mode 100755 index 000000000..15caf5fe4 --- /dev/null +++ b/docs/community-search/quick-start/test.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -eou pipefail + +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source 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_for_output 090_helm_add_mogodb_repo.sh +run_for_output 0100_install_operator.sh +run_for_output 0200_configure_community_search_pullsecret.sh +run_for_output 0210_verify_community_search_pullsecret.sh +run 0305_create_mongodb_community_user_secrets.sh +run 0310_create_mongodb_community_resource.sh +run 0315_wait_for_community_resource.sh +run 0320_create_mongodb_search_resource.sh +run 0325_wait_for_search_resource.sh +run 0330_wait_for_community_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_community_search_snippets_render_template.sh new file mode 100755 index 000000000..f7c86d1f7 --- /dev/null +++ b/scripts/code_snippets/kind_community_search_snippets_render_template.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -eou pipefail +source scripts/dev/set_env_context.sh + +test_dir="docs/community-search/quick-start" +python scripts/code_snippets/render_template.py "${test_dir}/README.md.j2" "${test_dir}/README.md" diff --git a/scripts/code_snippets/render_template.py b/scripts/code_snippets/render_template.py new file mode 100644 index 000000000..3d909baa1 --- /dev/null +++ b/scripts/code_snippets/render_template.py @@ -0,0 +1,24 @@ +import os +import sys + +from jinja2 import Environment, FileSystemLoader + +if len(sys.argv) != 3: + print("Usage: python render_template.py ") + sys.exit(1) + +template_file_path = sys.argv[1] +output_file_path = sys.argv[2] + +template_dir = os.path.dirname(os.path.abspath(template_file_path)) +template_filename = os.path.basename(template_file_path) + +env = Environment(loader=FileSystemLoader(searchpath=template_dir)) + +template = env.get_template(template_filename) + +rendered_content = template.render() +with open(output_file_path, "w") as f: + f.write(rendered_content) + +print(f"Template '{template_file_path}' rendered successfully to '{output_file_path}'") diff --git a/scripts/code_snippets/sample_commit_output.sh b/scripts/code_snippets/sample_commit_output.sh index ac84e9962..d54623980 100755 --- a/scripts/code_snippets/sample_commit_output.sh +++ b/scripts/code_snippets/sample_commit_output.sh @@ -9,6 +9,7 @@ if [ "${COMMIT_OUTPUT:-false}" = true ]; then git checkout -b "${branch}" git reset git add public/architectures/**/*.out + git add docs/**/output/*.out git commit -m "Update code snippets outputs" git remote set-url origin https://x-access-token:"${GH_TOKEN}"@github.com/mongodb/mongodb-kubernetes.git git push origin "${branch}" diff --git a/scripts/code_snippets/gke_multi_cluster_no_mesh_test.sh b/scripts/code_snippets/task_gke_multi_cluster_no_mesh_snippets_test.sh similarity index 100% rename from scripts/code_snippets/gke_multi_cluster_no_mesh_test.sh rename to scripts/code_snippets/task_gke_multi_cluster_no_mesh_snippets_test.sh diff --git a/scripts/code_snippets/gke_multi_cluster_test.sh b/scripts/code_snippets/task_gke_multi_cluster_snippets_test.sh similarity index 100% rename from scripts/code_snippets/gke_multi_cluster_test.sh rename to scripts/code_snippets/task_gke_multi_cluster_snippets_test.sh diff --git a/scripts/code_snippets/task_kind_community_search_snippets_test.sh b/scripts/code_snippets/task_kind_community_search_snippets_test.sh new file mode 100755 index 000000000..e53f04704 --- /dev/null +++ b/scripts/code_snippets/task_kind_community_search_snippets_test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eou pipefail +source scripts/dev/set_env_context.sh + +set -x + +dump_logs() { + source scripts/evergreen/e2e/dump_diagnostic_information.sh + dump_all_non_default_namespaces "$@" +} +trap dump_logs EXIT + +test_dir="./docs/community-search/quick-start" + +source "${test_dir}/env_variables.sh" +# 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_community_search_snippets_render_template.sh diff --git a/scripts/dev/contexts/private_kind_code_snippets b/scripts/dev/contexts/private_kind_code_snippets new file mode 100644 index 000000000..704957a6f --- /dev/null +++ b/scripts/dev/contexts/private_kind_code_snippets @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# this context file is for code snippets running on GKE clusters +set -Eeou pipefail + +# overrides of public env_variables.sh +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/root-context" + +export NAMESPACE=mongodb +export CODE_SNIPPETS_FLAVOR=e2e_private diff --git a/scripts/evergreen/e2e/dump_diagnostic_information.sh b/scripts/evergreen/e2e/dump_diagnostic_information.sh index 3408253d4..676928b05 100755 --- a/scripts/evergreen/e2e/dump_diagnostic_information.sh +++ b/scripts/evergreen/e2e/dump_diagnostic_information.sh @@ -8,9 +8,42 @@ set +e source scripts/funcs/printing +dump_all_non_default_namespaces() { + echo "Gathering logs from all non-default namespaces" + + local original_context + original_context="$(kubectl config current-context)" + kubectl config use-context "${1:-${original_context}}" &> /dev/null + prefix="${1:-${original_context}}_" + # shellcheck disable=SC2154 + if [[ "${KUBE_ENVIRONMENT_NAME:-}" != "multi" ]]; then + prefix="" + fi + + mkdir -p logs + namespaces=$(kubectl get namespace --output=jsonpath={.items..metadata.name} | tr ' ' '\n' | \ + grep -v "default" | \ + grep -v "kube-node-lease" | \ + grep -v "kube-node-lease" | \ + grep -v "kube-public" | \ + grep -v "kube-system" | \ + grep -v "local-path-storage" | \ + grep -v "metallb-system" + ) + + for ns in ${namespaces}; do + if kubectl get namespace "${ns}" -o jsonpath='{.metadata.annotations}'; then + echo "Dumping all diagnostic information for namespace ${ns}" + dump_namespace "${ns}" "${prefix}" + fi + done +} + dump_all() { [[ "${MODE-}" = "dev" ]] && return + mkdir -p logs + # TODO: provide a cleaner way of handling this. For now we run the same command with kubectl configured # with a different context. local original_context diff --git a/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh b/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh new file mode 100755 index 000000000..0734783a5 --- /dev/null +++ b/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -Eeou pipefail + +## We need to make sure this script does not fail if one of +## the kubectl commands fails. +set +e + +source scripts/funcs/printing +source scripts/evergreen/e2e/dump_diagnostic_information.sh + +dump_all_non_default_namespaces "$@" From 5bb86674e5bce3aa13c9953345a2b3010426809d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Mon, 12 May 2025 11:55:44 +0200 Subject: [PATCH 02/12] Update docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh Co-authored-by: Yavor Georgiev --- .../code_snippets/0315_wait_for_community_resource.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh b/docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh index a8f5e5b32..d1f423368 100644 --- a/docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh +++ b/docs/community-search/quick-start/code_snippets/0315_wait_for_community_resource.sh @@ -1,6 +1,6 @@ echo "Waiting for MongoDBCommunity resource to reach Running phase..." kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s -echo; echo "MongoDBOpsManager resource" +echo; echo "MongoDBCommunity resource" kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}" kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods From a3ab4bc20398804ef343a8c4edc9cf5274bb5f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Mon, 12 May 2025 11:55:58 +0200 Subject: [PATCH 03/12] Update docs/community-search/quick-start/README.md.j2 Co-authored-by: Yavor Georgiev --- docs/community-search/quick-start/README.md.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index adb3a9c7d..008d90627 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -60,7 +60,7 @@ To use MongoDB Search, your Kubernetes cluster needs to pull the necessary conta ```shell copy {% include "code_snippets/0200_configure_community_search_pullsecret.sh" %} ``` -This script creates a `docker-registry` secret in your Kubernetes namespace and associates it with the service account used for MongoDB pods. +This script creates a `community-private-preview-pullsecret` secret in your Kubernetes namespace and associates it with the service account used for MongoDB pods. ### 5. Verify Pull Secret Configuration From f58d156e8424e495140e1f11ce116753ec39751f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Mon, 12 May 2025 12:00:07 +0200 Subject: [PATCH 04/12] Update docs/community-search/quick-start/README.md.j2 Co-authored-by: Yavor Georgiev --- docs/community-search/quick-start/README.md.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index 008d90627..e4a1318da 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -179,7 +179,7 @@ To test the search functionality, this step imports the `sample_mflix.movies` co ```shell copy {% include "code_snippets/0420_import_movies_mflix_database.sh" %} ``` -This command uses `mongoimport` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. +This command uses `mongorestore` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. ### 15. Create Search Index From 8f8deb7c40b710efa736fc2dc6ac4bf87312867c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Mon, 12 May 2025 12:01:56 +0200 Subject: [PATCH 05/12] Review fixes --- docs/community-search/quick-start/README.md | 8 ++++---- docs/community-search/quick-start/README.md.j2 | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md index ae5641271..11ad9aa84 100644 --- a/docs/community-search/quick-start/README.md +++ b/docs/community-search/quick-start/README.md @@ -106,7 +106,7 @@ echo "ServiceAccount mongodb-kubernetes-database-pods has been patched: " kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -o yaml sa mongodb-kubernetes-database-pods ``` -This script creates a `docker-registry` secret in your Kubernetes namespace and associates it with the service account used for MongoDB pods. +This script creates a `community-private-preview-pullsecret` secret in your Kubernetes namespace and associates it with the service account used for MongoDB pods. ### 5. Verify Pull Secret Configuration @@ -217,7 +217,7 @@ After applying the `MongoDBCommunity` custom resource, the operator begins deplo ```shell copy echo "Waiting for MongoDBCommunity resource to reach Running phase..." kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s -echo; echo "MongoDBOpsManager resource" +echo; echo "MongoDBCommunity resource" kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}" kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods @@ -255,7 +255,7 @@ The `MongoDBSearch.spec` fields are supported: * `spec.statefulSet`: Optional statefulset overrides, which are applied last to the mongot's statefulset. It is possible to adjust any statefulset configuration that was create by the operator (the overrides are applied last). The type of the field is [apps/v1/StatefulSet](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#statefulset-v1-apps) and both `spec.statefulSet.spec` and `spec.statefulSet.metadata` fields are supported. * `spec.persistence.single`: optional storage configuration for MongoDB Search persistence volume containing storing search indexes. See [here](https://www.mongodb.com/docs/kubernetes/current/reference/k8s-operator-specification/#mongodb-setting-spec.podSpec.persistence.single) for more information about storage settings. MongoDBSearch reuses the same persistence type as in other custom resources (e.g. `MongoDB`), but supports only `single` persistence field. If not set, the operator sets `spec.persistence.single.storage = 10G`. * `spec.resourceRequirements` - resource requests and limits for mongodb-search container. It's recommended to use this field to customize resource allocations instead of overriding it via `spec.statefulSet` overrides. If not set, the operator sets the following values (no limits, only requests): -* ```yaml +```yaml requests: cpu: 2 memory: 2G @@ -345,7 +345,7 @@ mongorestore --archive=/tmp/sample_mflix.archive --verbose=1 --drop --nsInclude EOF )" ``` -This command uses `mongoimport` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. +This command uses `mongorestore` from the `mongodb-tools-pod` to load data from the downloaded `sample_mflix.archive` file. ### 15. Create Search Index diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index e4a1318da..d45cadf14 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -123,7 +123,7 @@ The `MongoDBSearch.spec` fields are supported: * `spec.statefulSet`: Optional statefulset overrides, which are applied last to the mongot's statefulset. It is possible to adjust any statefulset configuration that was create by the operator (the overrides are applied last). The type of the field is [apps/v1/StatefulSet](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#statefulset-v1-apps) and both `spec.statefulSet.spec` and `spec.statefulSet.metadata` fields are supported. * `spec.persistence.single`: optional storage configuration for MongoDB Search persistence volume containing storing search indexes. See [here](https://www.mongodb.com/docs/kubernetes/current/reference/k8s-operator-specification/#mongodb-setting-spec.podSpec.persistence.single) for more information about storage settings. MongoDBSearch reuses the same persistence type as in other custom resources (e.g. `MongoDB`), but supports only `single` persistence field. If not set, the operator sets `spec.persistence.single.storage = 10G`. * `spec.resourceRequirements` - resource requests and limits for mongodb-search container. It's recommended to use this field to customize resource allocations instead of overriding it via `spec.statefulSet` overrides. If not set, the operator sets the following values (no limits, only requests): -* ```yaml +```yaml requests: cpu: 2 memory: 2G From 52e26535f15460d1f3b2d64b14b1fa0ead3240f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 11:02:03 +0200 Subject: [PATCH 06/12] Update docs/community-search/quick-start/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Simon Bäumer --- docs/community-search/quick-start/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md index 11ad9aa84..679cd2e5e 100644 --- a/docs/community-search/quick-start/README.md +++ b/docs/community-search/quick-start/README.md @@ -225,7 +225,7 @@ kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods ### 9. Create MongoDB Search Resource -Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdbc-rs` to associate it with the MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. +Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdbc-rs` to automatically connect it with your deployed MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. Note: Private preview of MongoDB Community Search comes with some limitations, and it is not suitable for production use: * TLS cannot be enabled in MongoDB Community deployment (MongoD communicates with MongoT with plain text). From 7f1f1c8a0cdd7b16f5f4a2e7c1c63a0b196094ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 12:22:44 +0200 Subject: [PATCH 07/12] Update scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Simon Bäumer --- .../e2e/dump_diagnostic_information_from_all_namespaces.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh b/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh index 0734783a5..72571a811 100755 --- a/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh +++ b/scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -set -Eeou pipefail - ## We need to make sure this script does not fail if one of ## the kubectl commands fails. set +e From c3bd5af9a3174b3f42ac500382dbed9aa8d81c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 12:23:01 +0200 Subject: [PATCH 08/12] Update scripts/evergreen/e2e/dump_diagnostic_information.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Simon Bäumer --- scripts/evergreen/e2e/dump_diagnostic_information.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/evergreen/e2e/dump_diagnostic_information.sh b/scripts/evergreen/e2e/dump_diagnostic_information.sh index 676928b05..8b4ae7c84 100755 --- a/scripts/evergreen/e2e/dump_diagnostic_information.sh +++ b/scripts/evergreen/e2e/dump_diagnostic_information.sh @@ -21,7 +21,7 @@ dump_all_non_default_namespaces() { fi mkdir -p logs - namespaces=$(kubectl get namespace --output=jsonpath={.items..metadata.name} | tr ' ' '\n' | \ + namespaces=$(kubectl get namespace --output=jsonpath={.items[*].metadata.name} | tr ' ' '\n' | \ grep -v "default" | \ grep -v "kube-node-lease" | \ grep -v "kube-node-lease" | \ From e80393fbab40df685447eedee7881a834cc1c060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 13:01:58 +0200 Subject: [PATCH 09/12] Review fixes --- docs/community-search/quick-start/README.md | 7 ++++--- docs/community-search/quick-start/README.md.j2 | 5 +++-- .../task_kind_community_search_snippets_test.sh | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md index 679cd2e5e..f13e3ca33 100644 --- a/docs/community-search/quick-start/README.md +++ b/docs/community-search/quick-start/README.md @@ -4,13 +4,14 @@ This guide provides instructions for deploying MongoDB Community Edition along w ## Prerequisites +Community Search is currently in private preview, and access to the image requires a secret to pull the search container image from Quay.io. This secret is specified during the first step of the process below, and must be obtained from MongoDB when requesting access to the private preview. + 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). - **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. -- **jq**: A command-line JSON processor, used for parsing JSON output from kubectl commands. -- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Ensure you are using at least version 5. +- **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.k ## Setup Steps @@ -225,7 +226,7 @@ kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods ### 9. Create MongoDB Search Resource -Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdbc-rs` to automatically connect it with your deployed MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. +Once your MongoDB deployment is ready, enable Search capabilities by creating a `MongoDBSearch` custom resource, also named `mdbc-rs` to associate it with the MongoDB instance. This resource specifies the CPU and memory resource requirements for the search nodes. Note: Private preview of MongoDB Community Search comes with some limitations, and it is not suitable for production use: * TLS cannot be enabled in MongoDB Community deployment (MongoD communicates with MongoT with plain text). diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index d45cadf14..afeb73405 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -4,13 +4,14 @@ This guide provides instructions for deploying MongoDB Community Edition along w ## Prerequisites +Community Search is currently in private preview, and access to the image requires a secret to pull the search container image from Quay.io. This secret is specified during the first step of the process below, and must be obtained from MongoDB when requesting access to the private preview. + 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). - **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. -- **jq**: A command-line JSON processor, used for parsing JSON output from kubectl commands. -- **Bash 5.1+**: All shell commands in this guide are intended to be run in Bash. Ensure you are using at least version 5. +- **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.k ## Setup Steps diff --git a/scripts/code_snippets/task_kind_community_search_snippets_test.sh b/scripts/code_snippets/task_kind_community_search_snippets_test.sh index e53f04704..c85feac37 100755 --- a/scripts/code_snippets/task_kind_community_search_snippets_test.sh +++ b/scripts/code_snippets/task_kind_community_search_snippets_test.sh @@ -3,8 +3,6 @@ set -eou pipefail source scripts/dev/set_env_context.sh -set -x - dump_logs() { source scripts/evergreen/e2e/dump_diagnostic_information.sh dump_all_non_default_namespaces "$@" From 4f2c9353a3f8f3c9d15f4c4fb85fc9d1b0bf95c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 13:05:06 +0200 Subject: [PATCH 10/12] Review fixes --- docs/community-search/quick-start/README.md | 2 +- docs/community-search/quick-start/README.md.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md index f13e3ca33..01998f597 100644 --- a/docs/community-search/quick-start/README.md +++ b/docs/community-search/quick-start/README.md @@ -11,7 +11,7 @@ Before you begin, ensure you have the following tools and configurations in plac - **Kubernetes cluster**: A running Kubernetes cluster (e.g., Minikube, Kind, GKE, EKS, AKS). - **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.k +- **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. ## Setup Steps diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index afeb73405..ec2371869 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -11,7 +11,7 @@ Before you begin, ensure you have the following tools and configurations in plac - **Kubernetes cluster**: A running Kubernetes cluster (e.g., Minikube, Kind, GKE, EKS, AKS). - **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.k +- **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. ## Setup Steps From 54733be1e68bb84a08d667ca7c044164d8e08dbe Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Wed, 14 May 2025 14:43:03 +0200 Subject: [PATCH 11/12] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 552d9509a..81f9221df 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,7 +7,7 @@ * **MongoDBSearch (Community Private Preview)**: Added support for deploying MongoDB Search (Community Private Preview Edition) that enables full-text and vector search capabilities for MongoDBCommunity deployments. * Added new MongoDB CRD which is watched by default by the operator. - * For more information please see: `TBD LINK TO DOC MARKDOWN` + * For more information please see: [docs/community-search/quick-start/README.md](docs/community-search/quick-start/README.md) * Private Preview phase comes with some limitations: * minimum MongoDB Community version: 8.0. * TLS must be disabled in MongoDB (communication between mongot and mongod is in plaintext for now). From 1cec95f7bf7c9f8a6ac100a673e07033114d09d4 Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Wed, 14 May 2025 15:06:48 +0200 Subject: [PATCH 12/12] lint --- scripts/evergreen/e2e/dump_diagnostic_information.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/evergreen/e2e/dump_diagnostic_information.sh b/scripts/evergreen/e2e/dump_diagnostic_information.sh index 8b4ae7c84..f4ea7b986 100755 --- a/scripts/evergreen/e2e/dump_diagnostic_information.sh +++ b/scripts/evergreen/e2e/dump_diagnostic_information.sh @@ -21,7 +21,7 @@ dump_all_non_default_namespaces() { fi mkdir -p logs - namespaces=$(kubectl get namespace --output=jsonpath={.items[*].metadata.name} | tr ' ' '\n' | \ + namespaces=$(kubectl get namespace --output=jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | \ grep -v "default" | \ grep -v "kube-node-lease" | \ grep -v "kube-node-lease" | \