Skip to content

Commit

Permalink
fix: Rename selector in service and improvements in job mongo init
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Mar 24, 2024
1 parent c79b264 commit a365661
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions .k8s/mongo1-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ spec:
persistentVolumeClaim:
claimName: mongo1-claim0
strategy: {}
status: {}

---
apiVersion: batch/v1
Expand All @@ -44,5 +43,20 @@ 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"]
command:
- "/bin/bash"
- "-c"
- |
#!/bin/bash
echo "Mongo init"
sleep 30
mongosh --host mongo1:27017 <<EOF
cfg = {
"_id": "rs0",
"members": [
{ "_id": 0, "host": "mongo1:27017" }
]
};
rs.initiate(cfg);
EOF
restartPolicy: OnFailure
2 changes: 1 addition & 1 deletion .k8s/mongo1-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ spec:
port: 27017
targetPort: 27017
selector:
name: mongo1
app: mongo1
status:
loadBalancer: {}

0 comments on commit a365661

Please sign in to comment.