- Notifications
You must be signed in to change notification settings - Fork 23
CLOUDP-353164: Community/Enterprise Search TLS and cert manager changes #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anandsyncs wants to merge 51 commits into master Choose a base branch from anandsyncs/mck-search-enterprise-snippets-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
51 commits Select commit Hold shift + click to select a range
3ec055e [Search] Implement gRPC and mTLS
fealebenpae 6593b18 Merge remote-tracking branch 'origin/master' into fealebenpae/search-…
fealebenpae b791c36 fix external tests and snippets
fealebenpae 53e9334 try fix enterprise tests
fealebenpae cdc55d4 update unit tests for wireproto annotation
fealebenpae 83e9b33 bump version of mongod in external snippets
fealebenpae 14bedcf try fix external tests take 2
fealebenpae 8dc3d81 cheat linter
fealebenpae f4a1a34 remove searchCoordinator polyfill from external snippets
fealebenpae 75c83de update the port in external snippets
fealebenpae 83d91a0 remove upgrade test
fealebenpae 0c6fd48 tracer
anandsyncs 63813e3 env var unification
anandsyncs 843fd3b Merge branch 'fealebenpae/search-grpc' into anandsyncs/add-certmanage…
anandsyncs ab1718f expand on the wireproto override
fealebenpae cb83dbc changelog
fealebenpae 326ad85 Merge branch 'master' into fealebenpae/search-grpc
fealebenpae aa0dc82 rename force-wireproto annotation
fealebenpae 0b8bff0 tracer
anandsyncs fcb92ca cleanup
anandsyncs dae55bd tracer
anandsyncs fda22ee cleanup
anandsyncs 7ef1ae2 remove extra file
anandsyncs 4c38389 break down big snippet file
anandsyncs 060b7be Merge branch 'fealebenpae/search-grpc' into anandsyncs/add-certmanage…
anandsyncs 5231723 cleanup community
anandsyncs 714b2cc cleanup
anandsyncs 8d95b3f address pr comments
anandsyncs 1b80dd1 remove extraneous change
anandsyncs 86d13a7 use cluster issuer
anandsyncs 2010b55 Merge branch 'master' into anandsyncs/add-certmanager-community-searc…
anandsyncs 0a13ee9 use cluster issuer
anandsyncs a5fc3fc use tls stuff in uri
anandsyncs 648facd Remove enterprise search changes from community branch
anandsyncs 548fc39 cleanup
anandsyncs bdf65ef cleanup
anandsyncs 286e079 cleanup
anandsyncs a2906ab fix external snippet compatibility
anandsyncs 2a09806 update install cert manager script
anandsyncs d59c707 add enterprise snippets for search tls updates
anandsyncs fed0f08 add enterprise snippets for search tls updates
anandsyncs 764c831 Comm snippets squashed
fealebenpae ead9142 add enterprise snippets for search tls updates
anandsyncs c023c5e Removed redundant path separator in mongot config
lsierant 786a502 Lint
lsierant ca9d756 Add sleep to deflake enterprise snippets
lsierant 8e21bad add log fix
anandsyncs 7902e41 Merge remote-tracking branch 'origin/anandsyncs/mck-search-enterprise…
anandsyncs 5a129af Update docs/search/03-search-query-usage/env_variables.sh
lsierant a33ef9c Merge branch 'master' into anandsyncs/mck-search-enterprise-snippets-…
lsierant 594d800 fix lint
anandsyncs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -94,3 +94,5 @@ logs | |
| | ||
| # locally packaged chart | ||
| mongodb-kubernetes-*.tgz | ||
| | ||
| scripts/code_snippets/tests/outputs/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions 25 docs/search/01-search-community-deploy/code_snippets/01_0040_validate_env.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| required=( | ||
| K8S_CTX | ||
| MDB_NS | ||
| MDB_RESOURCE_NAME | ||
| MDB_VERSION | ||
| MDB_MEMBERS | ||
| CERT_MANAGER_NAMESPACE | ||
| MDB_TLS_CA_SECRET_NAME | ||
| MDB_TLS_SERVER_CERT_SECRET_NAME | ||
| MDB_SEARCH_TLS_SECRET_NAME | ||
| MDB_ADMIN_USER_PASSWORD | ||
| MDB_SEARCH_SYNC_USER_PASSWORD | ||
| MDB_USER_PASSWORD | ||
| OPERATOR_HELM_CHART | ||
| ) | ||
| | ||
| missing_req=() | ||
| for v in "${required[@]}"; do [[ -n "${!v:-}" ]] || missing_req+=("$v"); done | ||
| | ||
| if (( ${#missing_req[@]} )); then | ||
| echo "ERROR: Missing required environment variables:" >&2 | ||
| for m in "${missing_req[@]}"; do echo " - ${m}" >&2; done | ||
| else | ||
| echo "All required environment variables present." | ||
| fi |
22 changes: 13 additions & 9 deletions 22 ...01-search-community-deploy/code_snippets/01_0305_create_mongodb_community_user_secrets.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,16 @@ | ||
| kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ | ||
| create secret generic mdb-admin-user-password \ | ||
| --from-literal=password="${MDB_ADMIN_USER_PASSWORD}" | ||
| # Create admin user secret | ||
| kubectl create secret generic mdb-admin-user-password \ | ||
| --from-literal=password="${MDB_ADMIN_USER_PASSWORD}" \ | ||
| --dry-run=client -o yaml | kubectl apply --context "${K8S_CTX}" --namespace "${MDB_NS}" -f - | ||
| | ||
| kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ | ||
| create secret generic mdbc-rs-search-sync-source-password \ | ||
| --from-literal=password="${MDB_SEARCH_SYNC_USER_PASSWORD}" | ||
| # Create search sync source user secret | ||
| kubectl create secret generic "${MDB_RESOURCE_NAME}-search-sync-source-password" \ | ||
| --from-literal=password="${MDB_SEARCH_SYNC_USER_PASSWORD}" \ | ||
| --dry-run=client -o yaml | kubectl apply --context "${K8S_CTX}" --namespace "${MDB_NS}" -f - | ||
| | ||
| kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ | ||
| create secret generic mdb-user-password \ | ||
| --from-literal=password="${MDB_USER_PASSWORD}" | ||
| # Create regular user secret | ||
| kubectl create secret generic mdb-user-password \ | ||
| --from-literal=password="${MDB_USER_PASSWORD}" \ | ||
| --dry-run=client -o yaml | kubectl apply --context "${K8S_CTX}" --namespace "${MDB_NS}" -f - | ||
| | ||
| echo "User secrets created." |
15 changes: 15 additions & 0 deletions 15 docs/search/01-search-community-deploy/code_snippets/01_0306_install_cert_manager.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| helm upgrade --install \ | ||
| cert-manager \ | ||
| oci://quay.io/jetstack/charts/cert-manager \ | ||
| --kube-context "${K8S_CTX}" \ | ||
| --namespace "${CERT_MANAGER_NAMESPACE}" \ | ||
| --create-namespace \ | ||
| --set crds.enabled=true | ||
| | ||
| for deployment in cert-manager cert-manager-cainjector cert-manager-webhook; do | ||
| kubectl --context "${K8S_CTX}" \ | ||
| -n "${CERT_MANAGER_NAMESPACE}" \ | ||
| wait --for=condition=Available "deployment/${deployment}" --timeout=300s | ||
| done | ||
| | ||
| echo "cert-manager is ready in namespace ${CERT_MANAGER_NAMESPACE}." |
60 changes: 60 additions & 0 deletions 60 docs/search/01-search-community-deploy/code_snippets/01_0307_prepare_cert_manager_issuer.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Bootstrap a self-signed ClusterIssuer that will mint the CA material consumed by | ||
| # the MongoDBCommunity deployment. | ||
| kubectl apply --context "${K8S_CTX}" -f - <<EOF_MANIFEST | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: ClusterIssuer | ||
| metadata: | ||
| name: ${MDB_TLS_SELF_SIGNED_ISSUER} | ||
| spec: | ||
| selfSigned: {} | ||
| EOF_MANIFEST | ||
| | ||
| kubectl --context "${K8S_CTX}" wait --for=condition=Ready clusterissuer "${MDB_TLS_SELF_SIGNED_ISSUER}" | ||
| | ||
| # Create the CA certificate and secret in the cert-manager namespace. | ||
| kubectl apply --context "${K8S_CTX}" -f - <<EOF_MANIFEST | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: ${MDB_TLS_CA_CERT_NAME} | ||
| namespace: ${CERT_MANAGER_NAMESPACE} | ||
| spec: | ||
| isCA: true | ||
| commonName: ${MDB_TLS_CA_CERT_NAME} | ||
| secretName: ${MDB_TLS_CA_SECRET_NAME} | ||
| privateKey: | ||
| algorithm: ECDSA | ||
| size: 256 | ||
| issuerRef: | ||
| name: ${MDB_TLS_SELF_SIGNED_ISSUER} | ||
| kind: ClusterIssuer | ||
| EOF_MANIFEST | ||
| | ||
| kubectl --context "${K8S_CTX}" wait --for=condition=Ready -n "${CERT_MANAGER_NAMESPACE}" certificate "${MDB_TLS_CA_CERT_NAME}" | ||
| | ||
| # Publish a cluster-scoped issuer that fronts the generated CA secret so all namespaces can reuse it. | ||
| kubectl apply --context "${K8S_CTX}" -f - <<EOF_MANIFEST | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: ClusterIssuer | ||
| metadata: | ||
| name: ${MDB_TLS_CA_ISSUER} | ||
| spec: | ||
| ca: | ||
| secretName: ${MDB_TLS_CA_SECRET_NAME} | ||
| EOF_MANIFEST | ||
| | ||
| kubectl --context "${K8S_CTX}" wait --for=condition=Ready clusterissuer "${MDB_TLS_CA_ISSUER}" | ||
| | ||
| TMP_CA_CERT="$(mktemp)" | ||
| | ||
| kubectl --context "${K8S_CTX}" \ | ||
| get secret "${MDB_TLS_CA_SECRET_NAME}" -n "${CERT_MANAGER_NAMESPACE}" \ | ||
| -o jsonpath="{.data['ca\\.crt']}" | base64 --decode > "${TMP_CA_CERT}" | ||
| | ||
| # Expose the CA bundle through a ConfigMap for workloads and the MongoDBCommunity resource. | ||
| kubectl --context "${K8S_CTX}" create configmap "${MDB_TLS_CA_CONFIGMAP}" -n "${MDB_NS}" \ | ||
| --from-file=ca-pem="${TMP_CA_CERT}" --from-file=mms-ca.crt="${TMP_CA_CERT}" \ | ||
| --from-file=ca.crt="${TMP_CA_CERT}" \ | ||
| --dry-run=client -o yaml | kubectl --context "${K8S_CTX}" apply -f - | ||
| | ||
| echo "Cluster-wide CA issuer ${MDB_TLS_CA_ISSUER} is ready." |
70 changes: 70 additions & 0 deletions 70 docs/search/01-search-community-deploy/code_snippets/01_0308_issue_tls_certificates.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| server_certificate="${MDB_RESOURCE_NAME}-server-tls" | ||
| search_certificate="${MDB_RESOURCE_NAME}-search-tls" | ||
| | ||
| mongo_dns_names=() | ||
| for ((member = 0; member < MDB_MEMBERS; member++)); do | ||
| mongo_dns_names+=("${MDB_RESOURCE_NAME}-${member}") | ||
| mongo_dns_names+=("${MDB_RESOURCE_NAME}-${member}.${MDB_RESOURCE_NAME}-svc.${MDB_NS}.svc.cluster.local") | ||
| done | ||
| mongo_dns_names+=( | ||
| "${MDB_RESOURCE_NAME}-svc.${MDB_NS}.svc.cluster.local" | ||
| "*.${MDB_RESOURCE_NAME}-svc.${MDB_NS}.svc.cluster.local" | ||
| ) | ||
| | ||
| search_dns_names=( | ||
| "${MDB_RESOURCE_NAME}-search-svc.${MDB_NS}.svc.cluster.local" | ||
| ) | ||
| | ||
| render_dns_list() { | ||
| local dns_list=("$@") | ||
| for dns in "${dns_list[@]}"; do | ||
| printf " - \"%s\"\n" "${dns}" | ||
| done | ||
| } | ||
| | ||
| kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOF_MANIFEST | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: ${server_certificate} | ||
| namespace: ${MDB_NS} | ||
| spec: | ||
| secretName: ${MDB_TLS_SERVER_CERT_SECRET_NAME} | ||
| issuerRef: | ||
| name: ${MDB_TLS_CA_ISSUER} | ||
| kind: ClusterIssuer | ||
| duration: 240h0m0s | ||
| renewBefore: 120h0m0s | ||
| usages: | ||
| - digital signature | ||
| - key encipherment | ||
| - server auth | ||
| - client auth | ||
| dnsNames: | ||
| $(render_dns_list "${mongo_dns_names[@]}") | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: ${search_certificate} | ||
| namespace: ${MDB_NS} | ||
| spec: | ||
| secretName: ${MDB_SEARCH_TLS_SECRET_NAME} | ||
| issuerRef: | ||
| name: ${MDB_TLS_CA_ISSUER} | ||
| kind: ClusterIssuer | ||
| duration: 240h0m0s | ||
| renewBefore: 120h0m0s | ||
| usages: | ||
| - digital signature | ||
| - key encipherment | ||
| - server auth | ||
| - client auth | ||
| dnsNames: | ||
| $(render_dns_list "${search_dns_names[@]}") | ||
| EOF_MANIFEST | ||
| | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait --for=condition=Ready certificate "${server_certificate}" --timeout=300s | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait --for=condition=Ready certificate "${search_certificate}" --timeout=300s | ||
| | ||
| echo "MongoDB TLS certificates have been issued." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion 2 docs/search/01-search-community-deploy/code_snippets/01_0325_wait_for_search_resource.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| echo "Waiting for MongoDBSearch resource to reach Running phase..." | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \ | ||
| --for=jsonpath='{.status.phase}'=Running mdbs/mdbc-rs --timeout=300s | ||
| --for=jsonpath='{.status.phase}'=Running mdbs/"${MDB_RESOURCE_NAME}" --timeout=300s |
4 changes: 4 additions & 0 deletions 4 docs/search/01-search-community-deploy/code_snippets/01_0330_wait_for_community_resource.sh 100755 → 100644
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| echo "Waiting for MongoDBCommunity resource to reach Running phase..." | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait \ | ||
| --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s | ||
| echo; echo "MongoDBCommunity resource" | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get mdbc/mdbc-rs | ||
| echo; echo "Pods running in cluster ${K8S_CTX}" | ||
| kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get pods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions 28 docs/search/02-search-enterprise-deploy/code_snippets/02_0040_validate_env.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| required=( | ||
| K8S_CTX | ||
| MDB_NS | ||
| MDB_RESOURCE_NAME | ||
| MDB_VERSION | ||
| MDB_MEMBERS | ||
| CERT_MANAGER_NAMESPACE | ||
| MDB_TLS_CA_SECRET_NAME | ||
| MDB_TLS_SERVER_CERT_SECRET_NAME | ||
| MDB_SEARCH_TLS_SECRET_NAME | ||
| MDB_ADMIN_USER_PASSWORD | ||
| MDB_SEARCH_SYNC_USER_PASSWORD | ||
| MDB_USER_PASSWORD | ||
| OPERATOR_HELM_CHART | ||
| OPS_MANAGER_PROJECT_NAME | ||
| OPS_MANAGER_API_URL | ||
| OPS_MANAGER_API_USER | ||
| OPS_MANAGER_API_KEY | ||
| ) | ||
| | ||
| missing_req=() | ||
| for v in "${required[@]}"; do [[ -n "${!v:-}" ]] || missing_req+=("${v}"); done | ||
| if (( ${#missing_req[@]} )); then | ||
| echo "ERROR: Missing required environment variables:" >&2 | ||
| for m in "${missing_req[@]}"; do echo " - ${m}" >&2; done | ||
| else | ||
| echo "All required environment variables present." | ||
| fi |
15 changes: 15 additions & 0 deletions 15 docs/search/02-search-enterprise-deploy/code_snippets/02_0301_install_cert_manager.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| helm upgrade --install \ | ||
| cert-manager \ | ||
| oci://quay.io/jetstack/charts/cert-manager \ | ||
| --kube-context "${K8S_CTX}" \ | ||
| --namespace "${CERT_MANAGER_NAMESPACE}" \ | ||
| --create-namespace \ | ||
| --set crds.enabled=true | ||
| | ||
| for deployment in cert-manager cert-manager-cainjector cert-manager-webhook; do | ||
| kubectl --context "${K8S_CTX}" \ | ||
| -n "${CERT_MANAGER_NAMESPACE}" \ | ||
| wait --for=condition=Available "deployment/${deployment}" --timeout=300s | ||
| done | ||
| | ||
| echo "cert-manager is ready in namespace ${CERT_MANAGER_NAMESPACE}." |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not really related to snippets and it's a simple fix removing doubled // in mongot config.