Skip to content

Commit

Permalink
Bug: MongoServerError: not primary and secondaryOk=false #106
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Mar 24, 2024
1 parent 3df7201 commit c79b264
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 67 deletions.
38 changes: 22 additions & 16 deletions .k8s/mongo1-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,39 @@ spec:
replicas: 1
selector:
matchLabels:
name: mongo1
strategy:
type: Recreate
app: mongo1
template:
metadata:
creationTimestamp: null
labels:
name: mongo1
app: mongo1
spec:
containers:
- args:
- --bind_ip_all
- --replSet
- rs0
- name: mongo1
image: mongo:6
name: mongo1
command: ["mongod", "--bind_ip_all", "--replSet", "rs0"]
ports:
- containerPort: 27017
hostPort: 27017
protocol: TCP
resources: {}
volumeMounts:
- mountPath: /data/db
name: mongo1-claim0
restartPolicy: Always
- name: mongo1-claim0
mountPath: /data/db
volumes:
- name: mongo1-claim0
persistentVolumeClaim:
claimName: mongo1-claim0
status: {}
strategy: {}
status: {}

---
apiVersion: batch/v1
kind: Job
metadata:
name: mongodb-init
spec:
template:
spec:
containers:
- name: mongodb-init
image: mongo:6
command: ["/bin/bash", "-c", "sleep 15 && until nc -zv mongo1 27017; do echo 'Waiting for mongo1 to be ready...'; sleep 5; done; sleep 10; mongosh --host mongo1:27017 <<EOF; cfg = { '_id': 'rs0', 'members': [ { '_id': 0, 'host': 'mongo1:27017' } ] }; rs.initiate(cfg); EOF"]
restartPolicy: OnFailure
14 changes: 0 additions & 14 deletions .k8s/mongodb-claim0-persistentvolumeclaim.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions .k8s/mongodb-pod.yaml

This file was deleted.

0 comments on commit c79b264

Please sign in to comment.