Skip to content

Commit

Permalink
feat: add init-db.sh script for database initialization in control-pl…
Browse files Browse the repository at this point in the history
…ane job
  • Loading branch information
jordancarrier committed Jan 24, 2025
1 parent 147370c commit f5a4c9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ data:
{{- range $key, $value := .Values.config.core.data }}
{{ $key }}: {{ $value | quote }}
{{- end }}
init-db.sh: |
#!/bin/bash
mongosh -u $MongoDB__User -p $MongoDB__Password mongodb://$MongoDB__Host:$MongoDB__Port/database? --eval "db.PartitionData.drop()"
mongosh -u $MongoDB__User -p $MongoDB__Password mongodb://$MongoDB__Host:$MongoDB__Port/database? --eval "db.PartitionData.insertMany([{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'bench'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'default'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'htcmock'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'stream'}])"
21 changes: 13 additions & 8 deletions charts/armonik/charts/control-plane/templates/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ spec:
- name: job-partitions-in-database
image: rtsp/mongosh:2.3.8
imagePullPolicy: IfNotPresent
command:
- |
<<EOF
mongosh -u $MongoDB__User -p $MongoDB__Password mongodb://$MongoDB__Host:$MongoDB__Port/database?authSource=$MongoDB__AuthSource --eval "db.PartitionData.drop()"
mongosh -u $MongoDB__User -p $MongoDB__Password mongodb://$MongoDB__Host:$MongoDB__Port/database?authSource=$MongoDB__AuthSource --eval "db.PartitionData.insertMany([{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'bench'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'default'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'htcmock'},{'ParentPartitionIds':[],'PodConfiguration':null,'PodMax':100,'PodReserved':1,'PreemptionPercentage':50,'Priority':1,'_id':'stream'}])"
EOF
command: ["/script/init-db.sh"]
env:
- name: MongoDB__Password
valueFrom:
Expand All @@ -44,6 +39,10 @@ spec:
optional: false
- name: MongoDB__User
value: root
- name: MongoDB__Host
value: "{{ .Values.config.core.data.MongoDB__Host }}"
- name: MongoDB__Port
value: "{{ .Values.config.core.data.MongoDB__Port }}"
envFrom:
- configMapRef:
name: jobs-configmap
Expand All @@ -57,6 +56,8 @@ spec:
- name: mongodb-crt
mountPropagation: None
mountPath: /mongodb/certs/
- name: script
mountPath: "/script"
dnsPolicy: ClusterFirst
shareProcessNamespace: false
terminationGracePeriodSeconds: 30
Expand All @@ -66,7 +67,7 @@ spec:
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
{{- if .Values.tolerations }}
tolerations:
{{- toYaml .Values.tolerations | nindent 8 }}
{{- end }}
Expand All @@ -75,4 +76,8 @@ spec:
secret:
defaultMode: 420
optional: false
secretName: mongodb-crt
secretName: mongodb-crt
- name: script
configMap:
name: jobs-configmap
defaultMode: 0500

0 comments on commit f5a4c9b

Please sign in to comment.