Skip to content
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

Proposed fixes #10 & #11 plus some numactl and wireTiger parameters #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions resources/mongodb-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ spec:
ports:
- port: 27017
targetPort: 27017
clusterIP: None
# clusterIP: None # Set to "clusterIP: None" unless external access is required
selector:
role: mongo
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongod
spec:
serviceName: mongodb-service
replicas: 3
selector:
matchLabels:
app: app_mongod
template:
metadata:
labels:
app: app_mongod
role: mongo
environment: test
replicaset: MainRepSet
Expand Down Expand Up @@ -49,11 +53,11 @@ spec:
#image: pkdone/mongo-ent:3.4
image: mongo
command:
- "numactl"
- "--interleave=all"
# - "numactl"
# - "--interleave=all"
- "mongod"
- "--wiredTigerCacheSizeGB"
- "0.1"
- "0.25"
- "--bind_ip"
- "0.0.0.0"
- "--replSet"
Expand Down
8 changes: 7 additions & 1 deletion scripts/configure_repset_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi

# Initiate replica set configuration
echo "Configuring the MongoDB Replica Set"
kubectl exec mongod-0 -c mongod-container -- mongo --eval 'rs.initiate({_id: "MainRepSet", version: 1, members: [ {_id: 0, host: "mongod-0.mongodb-service.default.svc.cluster.local:27017"}, {_id: 1, host: "mongod-1.mongodb-service.default.svc.cluster.local:27017"}, {_id: 2, host: "mongod-2.mongodb-service.default.svc.cluster.local:27017"} ]});'
kubectl exec mongod-0 -c mongod-container -- mongo --eval 'rs.initiate({_id: "MainRepSet", version: 1, members: [ {_id: 0, host: "mongod-0.mongodb-service.default.svc.cluster.local:27017", priority: 1}, {_id: 1, host: "mongod-1.mongodb-service.default.svc.cluster.local:27017", priority: 0.5}, {_id: 2, host: "mongod-2.mongodb-service.default.svc.cluster.local:27017", priority: 0.5} ]});'

# Wait a bit until the replica set should have a primary ready
echo "Waiting for the Replica Set to initialise..."
Expand All @@ -30,3 +30,9 @@ echo "Creating user: 'main_admin'"
kubectl exec mongod-0 -c mongod-container -- mongo --eval 'db.getSiblingDB("admin").createUser({user:"main_admin",pwd:"'"${1}"'",roles:[{role:"root",db:"admin"}]});'
echo

# Create a local port forwarding to connect mongodb clients
echo " Creating port forward for mongodb-service to: 127.0.0.1:27017"
kubectl port-forward service/mongodb-service 27017:27017 &
echo "Connect string: mongodb://main_admin:<YOUR_PASSWORD>@0.0.0.0:27017/?authSource=admin&replicaSet=MainRepSet&readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false"
echo

2 changes: 1 addition & 1 deletion scripts/teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ kubectl delete secret shared-bootstrap-data
sleep 3

# Delete persistent volume claims
kubectl delete persistentvolumeclaims -l role=mongo
kubectl delete persistentvolumeclaims -l app=app_mongod