Skip to content

Commit dae55bd

Browse files
committed
tracer
1 parent fcb92ca commit dae55bd

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

docs/search/01-search-community-deploy/code_snippets/01_0306_create_mongodb_tls_secrets.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,11 @@ create_tls_secret "${MDB_TLS_CA_SECRET_NAME}" "${tmpdir}/ca.crt" "" "generic"
170170
create_tls_secret "${MDB_TLS_SERVER_CERT_SECRET_NAME}" "${tmpdir}/mongodb.crt" "${tmpdir}/mongodb.key"
171171
create_tls_secret "${MDB_SEARCH_TLS_SECRET_NAME}" "${tmpdir}/mongot.crt" "${tmpdir}/mongot.key"
172172

173-
echo "TLS certificates and secrets created successfully"
173+
echo "Creating CA ConfigMap ${MDB_TLS_CA_CONFIGMAP_NAME}..."
174+
kubectl create configmap "${MDB_TLS_CA_CONFIGMAP_NAME}" \
175+
--from-file=ca.crt="${tmpdir}/ca.crt" \
176+
--from-file=ca-pem="${tmpdir}/ca.crt" \
177+
--dry-run=client -o yaml \
178+
| kubectl apply --context "${K8S_CTX}" --namespace "${MDB_NS}" -f -
179+
180+
echo "TLS certificates, secrets, and CA ConfigMap created successfully"

docs/search/01-search-community-deploy/code_snippets/01_0307_optional_cert_manager_tls.sh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,46 @@
22
set -euo pipefail
33

44
# Always provision cert-manager TLS assets in a fresh environment.
5-
# Installs cert-manager (v1.19.1), waits for webhook readiness, then creates:
5+
# Installs cert-manager, waits for webhook readiness, then creates:
66
# - Self-signed Issuer
77
# - CA Certificate (secret)
88
# - CA Issuer
99
# - Server & Search Certificates
1010
# - CA ConfigMap (optional consumer)
1111

12+
: "${CERT_MANAGER_NAMESPACE:=cert-manager}"
13+
1214
required=(K8S_CTX MDB_NS MDB_RESOURCE_NAME MDB_TLS_CA_SECRET_NAME MDB_TLS_SERVER_CERT_SECRET_NAME MDB_SEARCH_TLS_SECRET_NAME MDB_TLS_CA_CONFIGMAP_NAME)
1315
missing=()
1416
for v in "${required[@]}"; do [[ -z "${!v:-}" ]] && missing+=("$v"); done
1517
if (( ${#missing[@]} )); then
1618
echo "Missing required env vars: ${missing[*]}" >&2; exit 1; fi
1719

18-
CERT_MANAGER_VERSION="${CERT_MANAGER_VERSION:-v1.19.1}"
19-
2020
install_cert_manager() {
21-
echo "Installing cert-manager ${CERT_MANAGER_VERSION}..."
22-
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.crds.yaml"
23-
helm repo add jetstack https://charts.jetstack.io >/dev/null 2>&1 || true
24-
helm repo update >/dev/null 2>&1 || true
21+
echo "Installing cert-manager..."
22+
helm repo add jetstack https://charts.jetstack.io --force-update >/dev/null 2>&1 || true
2523
helm upgrade --install cert-manager jetstack/cert-manager \
26-
-n cert-manager --create-namespace \
27-
--version "${CERT_MANAGER_VERSION}" \
28-
--set installCRDs=false \
29-
--set global.leaderElection.namespace=cert-manager \
30-
--set webhook.timeoutSeconds=30 1>/dev/null
24+
--kube-context "${K8S_CTX}" \
25+
--namespace "${CERT_MANAGER_NAMESPACE}" \
26+
--create-namespace \
27+
--set crds.enabled=true 1>/dev/null
3128

3229
echo "Waiting for cert-manager deployments to be Available..."
3330
for dep in cert-manager cert-manager-cainjector cert-manager-webhook; do
34-
kubectl wait -n cert-manager --for=condition=Available deployment/${dep} --timeout=300s || {
31+
kubectl --context "${K8S_CTX}" wait -n "${CERT_MANAGER_NAMESPACE}" --for=condition=Available deployment/${dep} --timeout=300s || {
3532
echo "ERROR: deployment ${dep} not Available" >&2; exit 1; }
3633
done
3734

3835
echo "Waiting for webhook service existence..."
3936
local tries=0 max_tries=30
40-
until kubectl get svc cert-manager-webhook -n cert-manager >/dev/null 2>&1; do
37+
until kubectl --context "${K8S_CTX}" get svc cert-manager-webhook -n "${CERT_MANAGER_NAMESPACE}" >/dev/null 2>&1; do
4138
((tries++)); [[ $tries -ge $max_tries ]] && { echo "ERROR: cert-manager-webhook service not found" >&2; exit 1; }
4239
sleep 5
4340
done
4441

4542
echo "Waiting for webhook endpoints to have at least one address..."
4643
tries=0
47-
until [[ $(kubectl get endpoints cert-manager-webhook -n cert-manager -o jsonpath='{.subsets[0].addresses[0].ip}' 2>/dev/null || echo '') != '' ]]; do
44+
until [[ $(kubectl --context "${K8S_CTX}" get endpoints cert-manager-webhook -n "${CERT_MANAGER_NAMESPACE}" -o jsonpath='{.subsets[0].addresses[0].ip}' 2>/dev/null || echo '') != '' ]]; do
4845
((tries++)); [[ $tries -ge $max_tries ]] && { echo "ERROR: webhook endpoints have no addresses" >&2; exit 1; }
4946
sleep 5
5047
done
@@ -184,10 +181,16 @@ fi
184181
if ! kubectl get configmap "${MDB_TLS_CA_CONFIGMAP_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" >/dev/null 2>&1; then
185182
ca_b64=$(kubectl get secret "${MDB_TLS_CA_SECRET_NAME}" --context "${K8S_CTX}" -n "${MDB_NS}" -o jsonpath='{.data.ca\.crt}' || true)
186183
if [[ -n "$ca_b64" ]]; then
187-
printf '%s' "$ca_b64" | base64 --decode > /tmp/ca.crt
188-
kubectl create configmap "${MDB_TLS_CA_CONFIGMAP_NAME}" --from-file=ca-pem=/tmp/ca.crt --from-file=ca.crt=/tmp/ca.crt --dry-run=client -o yaml | kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f -
189-
rm -f /tmp/ca.crt
184+
tmp_ca_file="$(mktemp)"
185+
printf '%s' "$ca_b64" | base64 --decode > "${tmp_ca_file}"
186+
kubectl create configmap "${MDB_TLS_CA_CONFIGMAP_NAME}" \
187+
--context "${K8S_CTX}" \
188+
--from-file=ca-pem="${tmp_ca_file}" \
189+
--from-file=ca.crt="${tmp_ca_file}" \
190+
--dry-run=client -o yaml \
191+
| kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f -
192+
rm -f "${tmp_ca_file}"
190193
fi
191194
fi
192195

193-
echo "Community cert-manager TLS assets ready (v${CERT_MANAGER_VERSION})."
196+
echo "Community cert-manager TLS assets ready."

docs/search/01-search-community-deploy/code_snippets/01_0310_create_mongodb_community_resource.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ spec:
1212
enabled: true
1313
certificateKeySecretRef:
1414
name: ${MDB_TLS_SERVER_CERT_SECRET_NAME}
15+
# If both the CA secret and ConfigMap are defined, the operator uses the secret and ignores the ConfigMap.
16+
caCertificateSecretRef:
17+
name: ${MDB_TLS_CA_SECRET_NAME}
1518
caConfigMapRef:
1619
name: ${MDB_TLS_CA_CONFIGMAP_NAME}
1720
authentication:

0 commit comments

Comments
 (0)