Skip to content

Commit

Permalink
Use template to generate argocd hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Nov 11, 2024
1 parent beace11 commit 571038c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
22 changes: 0 additions & 22 deletions helm/templates/argo-hooks/collect-static.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions helm/templates/argo-hooks/database-migration.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions helm/templates/argo-hooks/hook-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- range $hookName, $hook := .Values.argoHooks }}

{{- if $hook.enabled }}

---
apiVersion: batch/v1
kind: Job
metadata:
generateName: {{ template "tc-chatbot-backend.fullname" $ }}-{{ $hookName }}-
annotations:
argocd.argoproj.io/hook: {{ $hook.hook }}
spec:
template:
metadata:
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/config/secret.yaml") $ | sha256sum }}
checksum/configmap: {{ include (print $.Template.BasePath "/config/configmap.yaml") $ | sha256sum }}
spec:
restartPolicy: "Never"
containers:
- name: {{ $.Chart.Name }}-{{ $hookName }}
image: "{{ $.Values.image.name }}:{{ $.Values.image.tag }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
command:
{{- range $hook.command }}
- "{{ . }}"
{{- end }}
resources:
requests:
cpu: {{ default $.Values.api.resources.requests.cpu $hook.requestsCpu }}
memory: {{ default $.Values.api.resources.requests.memory $hook.requestsMemory }}
limits:
cpu: {{ default $.Values.api.resources.limits.cpu $hook.limitsCpu }}
memory: {{ default $.Values.api.resources.limits.memory $hook.limitsMemory }}
envFrom:
- secretRef:
name: {{ template "tc-chatbot-backend.fullname" $ }}-api-secret
- configMapRef:
name: {{ template "tc-chatbot-backend.fullname" $ }}-api-configmap

{{- end }}

{{- end }}
11 changes: 9 additions & 2 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ qdrant:
memory: 200Mi

argoHooks:
enableDatabaseMigration: true
enableCollectStatic: true
# NOTE: Make sure key are lowercase
database-migration:
enabled: true
hook: PostSync
command: ["./manage.py", "migrate"]
collect-static:
enabled: true
hook: PostSync
command: ["./manage.py", "collectstatic", "--noinput"]

# TODO: persistence for uploaded files
api:
Expand Down

0 comments on commit 571038c

Please sign in to comment.