Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Argo hooks Implementation #2320

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions deploy/helm/ifrcgo-helm/templates/argo-hooks/hook-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- range $hookName, $hook := .Values.argoHooks }}

{{- if $hook.enabled }}

---
apiVersion: batch/v1
kind: Job
metadata:
{{- if $hook.preserveHistory }}
generateName: {{ template "ifrcgo-helm.fullname" $ }}-{{ $hookName }}-
{{- else }}
name: {{ template "ifrcgo-helm.fullname" $ }}-{{ $hookName }}
{{- end }}
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 }}
thenav56 marked this conversation as resolved.
Show resolved Hide resolved
spec:
restartPolicy: "Never"
containers:
- name: {{ $.Chart.Name }}-{{ $hookName }}
thenav56 marked this conversation as resolved.
Show resolved Hide resolved
image: "{{ $.Values.api.image.name }}:{{ $.Values.api.image.tag }}"
imagePullPolicy: {{ $.Values.api.image.pullPolicy }}
command: {{ toYaml $hook.command | trim | nindent 12 }}
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 "ifrcgo-helm.fullname" $ }}-api-secret
- configMapRef:
name: {{ template "ifrcgo-helm.fullname" $ }}-api-configmap

{{- end }}

{{- end }}
3 changes: 3 additions & 0 deletions deploy/helm/ifrcgo-helm/templates/celery/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
run: {{ .Release.Name }}-celery
template:
metadata:
annotations:
checksum/secret: {{ include (print .Template.BasePath "/config/secret.yaml") . | sha256sum }}
checksum/configmap: {{ include (print .Template.BasePath "/config/configmap.yaml") . | sha256sum }}
labels:
app: {{ template "ifrcgo-helm.name" . }}
release: {{ .Release.Name }}
Expand Down
13 changes: 13 additions & 0 deletions deploy/helm/ifrcgo-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ api:
image:
name: 'SET-BY-CHARTPRESS'
tag: 'set-by-chartpress'
pullPolicy: 'IfNotPresent'
resources:
requests:
cpu: "2"
Expand Down Expand Up @@ -108,6 +109,18 @@ celery:
cpu: "2"
memory: 4Gi

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

cronjobs:
- command: 'index_and_notify'
schedule: '*/5 * * * *'
Expand Down
Loading