Skip to content

Commit f824774

Browse files
committed
wip
1 parent 31c0360 commit f824774

File tree

91 files changed

+556
-1378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+556
-1378
lines changed

.evergreen-snippets.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ tasks:
6666
- func: test_code_snippets
6767
- func: sample_commit_output
6868

69-
- name: test_kind_search_enterprise_snippets.sh
70-
tags: [ "code_snippets", "patch-run" ]
71-
commands:
72-
- func: test_code_snippets
73-
- func: sample_commit_output
74-
7569
task_groups:
7670
- name: gke_code_snippets_task_group
7771
<<: *setup_and_teardown_group_gke_code_snippets
@@ -85,7 +79,6 @@ task_groups:
8579
max_hosts: -1
8680
tasks:
8781
- test_kind_search_community_snippets.sh
88-
- test_kind_search_enterprise_snippets.sh
8982

9083
buildvariants:
9184
# These variants are used to test the code snippets and each one can be used in patches
@@ -117,7 +110,7 @@ buildvariants:
117110
allowed_requesters: [ "patch" ]
118111
run_on:
119112
- ubuntu2204-small
120-
# <<: *base_om8_dependency
113+
<<: *base_om8_dependency
121114
tasks:
122115
- name: gke_code_snippets_task_group
123116

docs/search/01-search-community-deploy/README.md renamed to docs/community-search/quick-start/README.md

Lines changed: 27 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ Download or copy the content of `env_variables.sh`:
2727
[env_variables.sh](env_variables.sh)
2828
```shell copy
2929
# set it to the context name of the k8s cluster
30-
export K8S_CTX="<local cluster context>"
30+
export K8S_CLUSTER_0_CONTEXT_NAME="<local cluster context>"
3131

3232
# At the private preview stage the community search image is accessible only from a private repository.
3333
# Please contact MongoDB Support to get access.
3434
export PRIVATE_PREVIEW_IMAGE_PULLSECRET="<.dockerconfigjson>"
3535

3636
# the following namespace will be created if not exists
37-
export MDB_NS="mongodb"
37+
export MDB_NAMESPACE="mongodb"
3838

3939
export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME"
4040
export MDB_SEARCH_USER_PASSWORD="search-user-password-CHANGE-ME"
@@ -62,9 +62,9 @@ Next, install the MongoDB Kubernetes Operator from the Helm repository you just
6262

6363
[code_snippets/0100_install_operator.sh](code_snippets/0100_install_operator.sh)
6464
```shell copy
65-
helm upgrade --install --debug --kube-context "${K8S_CTX}" \
65+
helm upgrade --install --debug --kube-context "${K8S_CLUSTER_0_CONTEXT_NAME}" \
6666
--create-namespace \
67-
--namespace="${MDB_NS}" \
67+
--namespace="${MDB_NAMESPACE}" \
6868
mongodb-kubernetes \
6969
--set "${OPERATOR_ADDITIONAL_HELM_VALUES:-"dummy=value"}" \
7070
"${OPERATOR_HELM_CHART}"
@@ -133,28 +133,13 @@ MongoDB requires authentication for secure access. This step creates two Kuberne
133133

134134
[code_snippets/0305_create_mongodb_community_user_secrets.sh](code_snippets/0305_create_mongodb_community_user_secrets.sh)
135135
```shell copy
136-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
137136
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" --namespace "${MDB_NAMESPACE}" \
138137
create secret generic admin-user-password \
139138
--from-literal=password="${MDB_ADMIN_USER_PASSWORD}"
140139

141140
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" --namespace "${MDB_NAMESPACE}" \
142141
create secret generic search-user-password \
143142
--from-literal=password="${MDB_SEARCH_USER_PASSWORD}"
144-
========
145-
kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \
146-
create secret generic mdb-admin-user-password \
147-
--from-literal=password="${MDB_ADMIN_USER_PASSWORD}"
148-
149-
kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \
150-
create secret generic mdbc-rs-search-sync-source-password \
151-
--from-literal=password="${MDB_SEARCH_SYNC_USER_PASSWORD}"
152-
153-
kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \
154-
create secret generic mdb-user-password \
155-
--from-literal=password="${MDB_USER_PASSWORD}"
156-
157-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
158143
```
159144
Ensure these secrets are created in the same namespace where you plan to deploy MongoDB.
160145

@@ -164,7 +149,7 @@ Now, deploy MongoDB Community by creating a `MongoDBCommunity` custom resource n
164149

165150
[code_snippets/0310_create_mongodb_community_resource.sh](code_snippets/0310_create_mongodb_community_resource.sh)
166151
```yaml copy
167-
kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF
152+
kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - <<EOF
168153
apiVersion: mongodbcommunity.mongodb.com/v1
169154
kind: MongoDBCommunity
170155
metadata:
@@ -202,7 +187,6 @@ spec:
202187
cpu: "1"
203188
memory: 5Gi
204189
users:
205-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
206190
- name: admin-user
207191
passwordSecretRef:
208192
name: admin-user-password
@@ -219,45 +203,6 @@ spec:
219203
- db: sample_mflix
220204
name: dbOwner
221205
scramCredentialsSecretName: search-user
222-
========
223-
# admin user with root role
224-
- name: mdb-admin
225-
db: admin
226-
# a reference to the secret containing user password
227-
passwordSecretRef:
228-
name: mdb-admin-user-password
229-
scramCredentialsSecretName: mdb-admin-user
230-
roles:
231-
- name: root
232-
db: admin
233-
# user performing search queries
234-
- name: mdb-user
235-
db: admin
236-
# a reference to the secret containing user password
237-
passwordSecretRef:
238-
name: mdb-user-password
239-
scramCredentialsSecretName: mdb-user-scram
240-
roles:
241-
- name: restore
242-
db: sample_mflix
243-
- name: readWrite
244-
db: sample_mflix
245-
# user used by MongoDB Search to connect to MongoDB database to
246-
# synchronize data from.
247-
# For MongoDB <8.2, the operator will be creating the
248-
# searchCoordinator custom role automatically.
249-
# From MongoDB 8.2, searchCoordinator role will be a
250-
# built-in role.
251-
- name: search-sync-source
252-
db: admin
253-
# a reference to the secret that will be used to generate the user's password
254-
passwordSecretRef:
255-
name: mdbc-rs-search-sync-source-password
256-
scramCredentialsSecretName: mdbc-rs-search-sync-source
257-
roles:
258-
- name: searchCoordinator
259-
db: admin
260-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
261206
EOF
262207
```
263208

@@ -268,12 +213,11 @@ After applying the `MongoDBCommunity` custom resource, the operator begins deplo
268213
[code_snippets/0315_wait_for_community_resource.sh](code_snippets/0315_wait_for_community_resource.sh)
269214
```shell copy
270215
echo "Waiting for MongoDBCommunity resource to reach Running phase..."
271-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \
272-
--for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
216+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
273217
echo; echo "MongoDBCommunity resource"
274-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get mdbc/mdbc-rs
275-
echo; echo "Pods running in cluster ${K8S_CTX}"
276-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get pods
218+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs
219+
echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}"
220+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods
277221
```
278222

279223
### 9. Create MongoDB Search Resource
@@ -286,7 +230,7 @@ Note: Private preview of MongoDB Community Search comes with some limitations, a
286230

287231
[code_snippets/0320_create_mongodb_search_resource.sh](code_snippets/0320_create_mongodb_search_resource.sh)
288232
```shell copy
289-
kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF
233+
kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - <<EOF
290234
apiVersion: mongodb.com/v1
291235
kind: MongoDBSearch
292236
metadata:
@@ -321,8 +265,7 @@ Similar to the MongoDB deployment, the Search deployment needs time to initializ
321265
[code_snippets/0325_wait_for_search_resource.sh](code_snippets/0325_wait_for_search_resource.sh)
322266
```shell copy
323267
echo "Waiting for MongoDBSearch resource to reach Running phase..."
324-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \
325-
--for=jsonpath='{.status.phase}'=Running mdbs/mdbc-rs --timeout=300s
268+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbs/mdbc-rs --timeout=300s
326269
```
327270
This command polls the status of the `MongoDBSearch` resource `mdbc-rs`.
328271

@@ -333,8 +276,7 @@ Double-check the status of your `MongoDBCommunity` resource to ensure it remains
333276
[code_snippets/0330_wait_for_community_resource.sh](code_snippets/0330_wait_for_community_resource.sh)
334277
```shell copy
335278
echo "Waiting for MongoDBCommunity resource to reach Running phase..."
336-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \
337-
--for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
279+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
338280
```
339281
This provides a final confirmation that the core database is operational.
340282

@@ -345,11 +287,11 @@ View all the running pods in your namespace. You should see pods for the MongoDB
345287
[code_snippets/0335_show_running_pods.sh](code_snippets/0335_show_running_pods.sh)
346288
```shell copy
347289
echo; echo "MongoDBCommunity resource"
348-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get mdbc/mdbc-rs
290+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs
349291
echo; echo "MongoDBSearch resource"
350-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get mdbs/mdbc-rs
351-
echo; echo "Pods running in cluster ${K8S_CTX}"
352-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get pods
292+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbs/mdbc-rs
293+
echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}"
294+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods
353295
```
354296

355297
## Using MongoDB Search
@@ -362,7 +304,9 @@ To interact with your MongoDB deployment, this step deploys a utility pod named
362304

363305
[code_snippets/0410_run_mongodb_tools_pod.sh](code_snippets/0410_run_mongodb_tools_pod.sh)
364306
```shell copy
365-
kubectl apply -n "${MDB_NS}" --context "${K8S_CTX}" -f - <<EOF
307+
#!/bin/bash
308+
309+
kubectl apply -n "${MDB_NAMESPACE}" --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -f - <<EOF
366310
apiVersion: v1
367311
kind: Pod
368312
metadata:
@@ -379,8 +323,7 @@ spec:
379323
EOF
380324
381325
echo "Waiting for the mongodb-tools to be ready..."
382-
kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \
383-
--for=condition=Ready pod/mongodb-tools-pod --timeout=60s
326+
kubectl wait --for=condition=Ready pod/mongodb-tools-pod -n "${MDB_NAMESPACE}" --context "${K8S_CLUSTER_0_CONTEXT_NAME}" --timeout=60s
384327
```
385328

386329
### 14. Import Sample Data
@@ -389,22 +332,13 @@ To test the search functionality, this step imports the `sample_mflix.movies` co
389332

390333
[code_snippets/0420_import_movies_mflix_database.sh](code_snippets/0420_import_movies_mflix_database.sh)
391334
```shell copy
392-
kubectl exec -n "${MDB_NS}" --context "${K8S_CTX}" \
393-
mongodb-tools-pod -- /bin/bash -eu -c "$(cat <<EOF
335+
#!/bin/bash
336+
337+
kubectl exec -n "${MDB_NAMESPACE}" --context "${K8S_CLUSTER_0_CONTEXT_NAME}" mongodb-tools-pod -- /bin/bash -eu -c "$(cat <<EOF
394338
echo "Downloading sample database archive..."
395-
curl https://atlas-education.s3.amazonaws.com/sample_mflix.archive \
396-
-o /tmp/sample_mflix.archive
339+
curl https://atlas-education.s3.amazonaws.com/sample_mflix.archive -o /tmp/sample_mflix.archive
397340
echo "Restoring sample database"
398-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
399341
mongorestore --archive=/tmp/sample_mflix.archive --verbose=1 --drop --nsInclude 'sample_mflix.*' --uri="mongodb://search-user:${MDB_SEARCH_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdbc-rs"
400-
========
401-
mongorestore \
402-
--archive=/tmp/sample_mflix.archive \
403-
--verbose=1 \
404-
--drop \
405-
--nsInclude 'sample_mflix.*' \
406-
--uri="mongodb://mdb-user:${MDB_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NS}.svc.cluster.local:27017/?replicaSet=mdbc-rs"
407-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
408342
EOF
409343
)"
410344
```
@@ -416,16 +350,10 @@ Before performing search queries, create a search index. This step uses `kubectl
416350

417351
[code_snippets/0430_create_search_index.sh](code_snippets/0430_create_search_index.sh)
418352
```shell copy
419-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
420353
#!/bin/bash
421354
422355
kubectl exec --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" mongodb-tools-pod -- \
423356
mongosh --quiet "mongodb://search-user:${MDB_SEARCH_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NAMESPACE}.svc.cluster.local:27017/?replicaSet=mdbc-rs" \
424-
========
425-
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" mongodb-tools-pod -- \
426-
mongosh --quiet \
427-
"mongodb://mdb-user:${MDB_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NS}.svc.cluster.local:27017/?replicaSet=mdbc-rs" \
428-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
429357
--eval "use sample_mflix" \
430358
--eval 'db.movies.createSearchIndex("default", { mappings: { dynamic: true } });'
431359
```
@@ -436,7 +364,6 @@ Creating a search index is an asynchronous operation. This script polls periodic
436364

437365
[code_snippets/0440_wait_for_search_index_ready.sh](code_snippets/0440_wait_for_search_index_ready.sh)
438366
```shell copy
439-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
440367
#!/bin/bash
441368
442369
for _ in $(seq 0 10); do
@@ -457,11 +384,6 @@ if [[ "${search_index_status}" != "READY" ]]; then
457384
echo "Error waiting for the search index to be ready"
458385
return 1
459386
fi
460-
========
461-
# Currently it's not possible to check the status of search indexes, we need to just wait
462-
echo "Sleeping to wait for search indexes to be created"
463-
sleep 60
464-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
465387
```
466388

467389
### 17. Execute a Search Query
@@ -470,6 +392,8 @@ Once the search index is ready, execute search queries using the `$search` aggre
470392

471393
[code_snippets/0450_execute_search_query.sh](code_snippets/0450_execute_search_query.sh)
472394
```shell copy
395+
#!/bin/bash
396+
473397
mdb_script=$(cat <<'EOF'
474398
use sample_mflix;
475399
db.movies.aggregate([
@@ -510,14 +434,9 @@ db.movies.aggregate([
510434
EOF
511435
)
512436
513-
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" \
514-
mongodb-tools-pod -- /bin/bash -eu -c "$(cat <<EOF
437+
kubectl exec --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" mongodb-tools-pod -- /bin/bash -eu -c "$(cat <<EOF
515438
echo '${mdb_script}' > /tmp/mdb_script.js
516-
<<<<<<<< HEAD:docs/community-search/quick-start/README.md
517439
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
518-
========
519-
mongosh --quiet "mongodb://mdb-user:${MDB_USER_PASSWORD}@mdbc-rs-0.mdbc-rs-svc.${MDB_NS}.svc.cluster.local:27017/?replicaSet=mdbc-rs" < /tmp/mdb_script.js
520-
>>>>>>>> 6309cff6f (Refactor of existing snippets on master):docs/search/01-search-community-deploy/README.md
521440
EOF
522441
)"
523442
```

0 commit comments

Comments
 (0)