This repository was archived by the owner on Jan 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
22 changes: 22 additions & 0 deletions
22
ansible/roles/mongo-repset/templates/init-configmap.yml.j2
This file contains 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,22 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: mongo-init-file | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: mongo-init | ||
data: | ||
update.sh: | | ||
#! /bin/bash | ||
until mongosh $MONGODB_URI --eval "print(\"waited for connection\")" | ||
do | ||
sleep 1 | ||
done | ||
mongosh $MONGODB_URI --eval 'rs.initiate({"_id" : "rs0", "members" : [{"_id" : 0, "host" : "mongodb-0:27017"},{"_id" : 0, "host" : "mongodb-1:27017"},{"_id" : 0, "host" : "mongodb-2:27017"}]})' | ||
sleep 30 | ||
if [[ $(mongosh --quiet --eval "db.isMaster().setName") != rs0 ]] | ||
then | ||
echo "replicaset config failed :(" | ||
else | ||
echo "gg, hacky mongo replicaset" | ||
fi |
This file contains 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,42 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: mongo-init-job | ||
labels: | ||
app: mongo-init | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: mongo-init | ||
image: quay.io/schulcloudverbund/infra-tools:latest | ||
envFrom: | ||
- secretRef: | ||
name: mongo-init-secret | ||
env: | ||
- name: K8S_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
volumeMounts: | ||
- name: script | ||
mountPath: /update.sh | ||
subPath: update.sh | ||
command: ['/bin/sh','-c'] | ||
args: ['cp /update.sh /update.run.sh && chmod +x /update.run.sh &&./update.run.sh'] | ||
resources: | ||
limits: | ||
cpu: "3000m" | ||
memory: "2Gi" | ||
requests: | ||
cpu: "100m" | ||
memory: "150Mi" | ||
volumes: | ||
- name: script | ||
configMap: | ||
name: mongo-init-file | ||
items: | ||
- key: update.sh | ||
path: update.sh | ||
restartPolicy: Never | ||
backoffLimit: 4 |
This file contains 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,9 @@ | ||
apiVersion: onepassword.com/v1 | ||
kind: OnePasswordItem | ||
metadata: | ||
name: mongo-init-secret | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: mongo-init | ||
spec: | ||
itemPath: "vaults/{{ ONEPASSWORD_OPERATOR_VAULT }}/items/devops-mongo-server-init" |