Skip to content

Commit 833a472

Browse files
committed
Reverted master search snippets
1 parent e8cfba7 commit 833a472

25 files changed

+836
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" create namespace "${MDB_NAMESPACE}"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - <<EOF
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: community-private-preview-pullsecret
6+
data:
7+
.dockerconfigjson: "${PRIVATE_PREVIEW_IMAGE_PULLSECRET}"
8+
type: kubernetes.io/dockerconfigjson
9+
EOF
10+
11+
pull_secrets=$(kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" \
12+
get sa mongodb-kubernetes-database-pods -n "${MDB_NAMESPACE}" -o=jsonpath='{.imagePullSecrets[*]}')
13+
14+
if [[ "${pull_secrets}" ]]; then
15+
kubectl patch --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" \
16+
sa mongodb-kubernetes-database-pods \
17+
--type=json -p='[{"op": "add", "path": "/imagePullSecrets/-", "value": {"name": "community-private-preview-pullsecret"}}]'
18+
else
19+
kubectl patch --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" \
20+
sa mongodb-kubernetes-database-pods \
21+
--type=merge -p='{"imagePullSecrets": [{"name": "community-private-preview-pullsecret"}]}'
22+
fi
23+
echo "ServiceAccount mongodb-kubernetes-database-pods has been patched: "
24+
25+
kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -o yaml sa mongodb-kubernetes-database-pods
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
echo "Verifying mongodb-kubernetes-database-pods service account contains proper pull secret"
2+
if ! kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -o json \
3+
sa mongodb-kubernetes-database-pods -o=jsonpath='{.imagePullSecrets[*]}' | \
4+
grep community-private-preview-pullsecret; then
5+
echo "ERROR: mongodb-kubernetes-database-pods service account doesn't contain necessary pullsecret"
6+
kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -o json \
7+
sa mongodb-kubernetes-database-pods -o=yaml
8+
return 1
9+
fi
10+
echo "SUCCESS: mongodb-kubernetes-database-pods service account contains proper pull secret"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" --namespace "${MDB_NAMESPACE}" \
2+
create secret generic admin-user-password \
3+
--from-literal=password="${MDB_ADMIN_USER_PASSWORD}"
4+
5+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" --namespace "${MDB_NAMESPACE}" \
6+
create secret generic search-user-password \
7+
--from-literal=password="${MDB_SEARCH_USER_PASSWORD}"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
kubectl apply --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -f - <<EOF
2+
apiVersion: mongodbcommunity.mongodb.com/v1
3+
kind: MongoDBCommunity
4+
metadata:
5+
name: mdbc-rs
6+
spec:
7+
version: 8.0.6
8+
type: ReplicaSet
9+
members: 3
10+
security:
11+
authentication:
12+
ignoreUnknownUsers: true
13+
modes:
14+
- SCRAM
15+
agent:
16+
logLevel: INFO
17+
statefulSet:
18+
spec:
19+
template:
20+
spec:
21+
containers:
22+
- name: mongod
23+
resources:
24+
limits:
25+
cpu: "3"
26+
memory: 5Gi
27+
requests:
28+
cpu: "2"
29+
memory: 5Gi
30+
- name: mongodb-agent
31+
resources:
32+
limits:
33+
cpu: "2"
34+
memory: 5Gi
35+
requests:
36+
cpu: "1"
37+
memory: 5Gi
38+
users:
39+
- name: admin-user
40+
passwordSecretRef:
41+
name: admin-user-password
42+
roles:
43+
- db: admin
44+
name: clusterAdmin
45+
- db: admin
46+
name: userAdminAnyDatabase
47+
scramCredentialsSecretName: admin-user
48+
- name: search-user
49+
passwordSecretRef:
50+
name: search-user-password
51+
roles:
52+
- db: sample_mflix
53+
name: dbOwner
54+
scramCredentialsSecretName: search-user
55+
EOF
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
echo "Waiting for MongoDBCommunity resource to reach Running phase..."
2+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
3+
echo; echo "MongoDBCommunity resource"
4+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs
5+
echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}"
6+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo "Waiting for MongoDBSearch resource to reach Running phase..."
2+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbs/mdbc-rs --timeout=300s
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo "Waiting for MongoDBCommunity resource to reach Running phase..."
2+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" wait --for=jsonpath='{.status.phase}'=Running mdbc/mdbc-rs --timeout=400s
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
echo; echo "MongoDBCommunity resource"
2+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbc/mdbc-rs
3+
echo; echo "MongoDBSearch resource"
4+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get mdbs/mdbc-rs
5+
echo; echo "Pods running in cluster ${K8S_CLUSTER_0_CONTEXT_NAME}"
6+
kubectl --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" get pods
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
kubectl exec -n "${MDB_NAMESPACE}" --context "${K8S_CLUSTER_0_CONTEXT_NAME}" mongodb-tools-pod -- /bin/bash -eu -c "$(cat <<EOF
4+
echo "Downloading sample database archive..."
5+
curl https://atlas-education.s3.amazonaws.com/sample_mflix.archive -o /tmp/sample_mflix.archive
6+
echo "Restoring sample database"
7+
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"
8+
EOF
9+
)"

0 commit comments

Comments
 (0)