Skip to content

Commit 12f405a

Browse files
authored
Clarify hostname and service name in external mongod search snippets (#483)
# Summary This pull request updates the configuration and code snippets for setting up an external MongoDB Search service to improve clarity and consistency in variable naming. The main change is the introduction of the `MDB_SEARCH_SERVICE_NAME` variable, replacing the previous use of `MDB_SEARCH_HOSTNAME` for Kubernetes service references, while `MDB_SEARCH_HOSTNAME` is now used specifically for the DNS hostname. **Configuration variable updates:** * Introduced `MDB_SEARCH_SERVICE_NAME` to represent the Kubernetes service name and updated all related references in `env_variables.sh` and `README.md`. The `MDB_SEARCH_HOSTNAME` variable is now used to specify the DNS hostname (e.g., `mdbs-search.example.com`). [[1]](diffhunk://#diff-e45215de7c861006344586b40839be9eff775ee82754ace9f0d83f208fcb127fL11-R12) [[2]](diffhunk://#diff-78a9bbf913195ad01e7814be0a2937858af6c019f895fa45726b5730974bc78cL53-R54) **Kubernetes service creation and referencing:** * Updated service creation in `04_0322_create_search_loadbalancer_service.sh` to use `MDB_SEARCH_SERVICE_NAME` for the service name instead of `MDB_SEARCH_HOSTNAME`. * Changed all `kubectl` commands and log messages in scripts to reference `MDB_SEARCH_SERVICE_NAME` instead of `MDB_SEARCH_HOSTNAME`, ensuring consistency throughout the deployment process. [[1]](diffhunk://#diff-3b631e2e08f0d1e1b57c8118a489bd479473d66343885e68b50f8614589a2954L16-R20) [[2]](diffhunk://#diff-7f7d23e97cadad8c2d81c63dab8f285f921bfbd83f39940febd47989a60986e1L1-R7) ## Proof of Work Snippet tests pass
1 parent e6e167f commit 12f405a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

docs/search/04-search-external-mongod/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export MDB_USER_PASSWORD="mdb-user-password-CHANGE-ME"
5050
# user for MongoDB Search to connect to the replica set to synchronise data from
5151
export MDB_SEARCH_SYNC_USER_PASSWORD="search-sync-user-password-CHANGE-ME"
5252

53-
export MDB_SEARCH_HOSTNAME="mdbs-search"
53+
export MDB_SEARCH_SERVICE_NAME="mdbs-search"
54+
export MDB_SEARCH_HOSTNAME="mdbs-search.example.com"
5455

5556
# External MongoDB replica set members - REPLACE THESE VALUES with your actual external MongoDB hosts
5657
# For testing purposes, these point to the MongoDB Community resource created by test.sh

docs/search/04-search-external-mongod/code_snippets/04_0322_create_search_loadbalancer_service.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<YAML
22
apiVersion: v1
33
kind: Service
44
metadata:
5-
name: ${MDB_SEARCH_HOSTNAME}
5+
name: ${MDB_SEARCH_SERVICE_NAME}
66
spec:
77
type: LoadBalancer
88
selector:
@@ -13,11 +13,11 @@ spec:
1313
targetPort: 27027
1414
YAML
1515

16-
echo "Waiting for external IP to be assigned to service ${MDB_SEARCH_HOSTNAME}..."
16+
echo "Waiting for external IP to be assigned to service ${MDB_SEARCH_SERVICE_NAME}..."
1717
TIMEOUT=120 # 2 minutes timeout
1818
ELAPSED=0
1919
while [ ${ELAPSED} -lt ${TIMEOUT} ]; do
20-
EXTERNAL_IP=$(kubectl get service "${MDB_SEARCH_HOSTNAME}" --context "${K8S_CTX}" -n "${MDB_NS}" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null)
20+
EXTERNAL_IP=$(kubectl get service "${MDB_SEARCH_SERVICE_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null)
2121
if [ -n "${EXTERNAL_IP}" ] && [ "${EXTERNAL_IP}" != "null" ]; then
2222
echo "External IP assigned: ${EXTERNAL_IP}"
2323
break

docs/search/04-search-external-mongod/code_snippets/04_0323_update_coredns_configmap.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
SEARCH_IP=$(kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get svc "${MDB_SEARCH_HOSTNAME}" -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
1+
SEARCH_IP=$(kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get svc "${MDB_SEARCH_SERVICE_NAME}" -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
22
if [ -z "${SEARCH_IP}" ]; then
3-
SEARCH_IP=$(kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get svc "${MDB_SEARCH_HOSTNAME}" -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
3+
SEARCH_IP=$(kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get svc "${MDB_SEARCH_SERVICE_NAME}" -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
44
fi
55

66
if [ -z "${SEARCH_IP}" ]; then
7-
echo "Error: Could not get LoadBalancer external IP/hostname for service ${MDB_SEARCH_HOSTNAME}"
7+
echo "Error: Could not get LoadBalancer external IP/hostname for service ${MDB_SEARCH_SERVICE_NAME}"
88
exit 1
99
fi
1010

docs/search/04-search-external-mongod/env_variables.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME"
88
export MDB_USER_PASSWORD="mdb-user-password-CHANGE-ME"
99
export MDB_SEARCH_SYNC_USER_PASSWORD="search-sync-user-password-CHANGE-ME"
1010

11-
export MDB_SEARCH_HOSTNAME="mdbs-search"
11+
export MDB_SEARCH_SERVICE_NAME="mdbs-search"
12+
export MDB_SEARCH_HOSTNAME="mdbs-search.example.com"
1213

1314
# External MongoDB replica set members - REPLACE THESE VALUES with your actual external MongoDB hosts
1415
# In production, replace with your actual external MongoDB replica set members

0 commit comments

Comments
 (0)