Skip to content

Commit

Permalink
feat: run aggregation job initially on deployment (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarmatei authored Jul 19, 2023
1 parent fcb28e1 commit a8fd976
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 43 deletions.
2 changes: 1 addition & 1 deletion charts/nx-cloud/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: nx-cloud
description: Nx Cloud Helm Chart
type: application
version: 0.10.8
version: 0.10.9
maintainers:
- name: nx
url: "https://nx.app/"
Expand Down
2 changes: 0 additions & 2 deletions charts/nx-cloud/templates/_auth-helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- define "nxCloud.api.auth" }}
# TODO update docs
# TODO test by adding different env vars and see if they get added on the deployment
{{- if .Values.github.auth.enabled }}
- name: GITHUB_AUTH_CLIENT_ID
valueFrom:
Expand Down
93 changes: 53 additions & 40 deletions charts/nx-cloud/templates/nx-cloud-aggregator-cron.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
{{- define "nxCloud.aggregator.template" }}
spec:
template:
spec:
containers:
- name: nx-cloud-aggregator
image: {{ include "nxCloud.images.aggregator.image" . }}
imagePullPolicy: {{ .Values.aggregator.image.pullPolicy | quote }}
{{- if .Values.aggregator.resources }}
resources: {{- toYaml .Values.aggregator.resources | nindent 16 }}
{{- end }}
env:
{{- include "nxCloud.env.mongoSecrets" . | indent 12 }}
{{- include "nxCloud.env.verboseLogging" . | indent 12 }}
{{- include "nxCloud.env.mode" . | indent 12 }}
{{- include "nxCloud.env.verboseMongoLogging" . | indent 12 }}
{{- if .Values.clearRecordsOlderThanDays }}
- name: NX_CLOUD_DB_RUN_DATA_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
- name: NX_CLOUD_DB_HASH_DATA_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
- name: NX_CLOUD_DB_HASH_DETAILS_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
{{- end }}
{{- if .Values.secret.adminPassword }}
{{- if .Values.secret.name }}
- name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.adminPassword }}
{{- else }}
- name: SECRET_FILE_ADMIN_PASSWORD
value: {{ .Values.secret.adminPassword }}
{{- end }}
{{- end }}
{{- if .Values.useCosmosDb }}
- name: NX_CLOUD_USE_MONGO42
value: 'false'
{{- end }}
restartPolicy: OnFailure
{{- end }}
---
apiVersion: batch/v1
kind: CronJob
Expand All @@ -9,43 +51,14 @@ spec:
schedule: '*/10 * * * *'
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- name: nx-cloud-aggregator
image: {{ include "nxCloud.images.aggregator.image" . }}
imagePullPolicy: {{ .Values.aggregator.image.pullPolicy | quote }}
{{- if .Values.aggregator.resources }}
resources: {{- toYaml .Values.aggregator.resources | nindent 16 }}
{{- end }}
env:
{{- include "nxCloud.env.mongoSecrets" . | indent 16 }}
{{- include "nxCloud.env.verboseLogging" . | indent 16 }}
{{- include "nxCloud.env.mode" . | indent 16 }}
{{- include "nxCloud.env.verboseMongoLogging" . | indent 16 }}
{{- if .Values.clearRecordsOlderThanDays }}
- name: NX_CLOUD_DB_RUN_DATA_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
- name: NX_CLOUD_DB_HASH_DATA_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
- name: NX_CLOUD_DB_HASH_DETAILS_EXPIRATION_IN_DAYS
value: '{{ .Values.clearRecordsOlderThanDays }}'
{{- end }}
{{- if .Values.secret.adminPassword }}
{{- if .Values.secret.name }}
- name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.adminPassword }}
{{- else }}
- name: SECRET_FILE_ADMIN_PASSWORD
value: {{ .Values.secret.adminPassword }}
{{- end }}
{{- end }}
{{- if .Values.useCosmosDb }}
- name: NX_CLOUD_USE_MONGO42
value: 'false'
{{- end }}
restartPolicy: OnFailure
{{- include "nxCloud.aggregator.template" . | indent 4 }}

---
apiVersion: batch/v1
kind: Job
metadata:
name: nx-cloud-initial-aggregation
labels:
{{- include "nxCloud.app.labels" . | indent 4 }}
{{- include "nxCloud.aggregator.template" . }}

0 comments on commit a8fd976

Please sign in to comment.