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 all 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
1 change: 1 addition & 0 deletions .github/workflows/build-publish-docker-helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Builds and pushes Docker Images and Helm charts to Github Registry
on:
# Build and push Docker image and Helm charts on every push to develop branch
# and on every tag push
workflow_dispatch:
push:
branches:
- develop
Expand Down
41 changes: 41 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,41 @@
{{- 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:
spec:
restartPolicy: "Never"
containers:
- name: {{ $hookName }}
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
2 changes: 1 addition & 1 deletion deploy/helm/ifrcgo-helm/templates/config/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data:
CACHE_REDIS_URL: "redis://{{ template "ifrcgo-helm.fullname" . }}-redis:6379/1"
CACHE_MIDDLEWARE_SECONDS: {{ .Values.env.CACHE_MIDDLEWARE_SECONDS | quote }}
DJANGO_DEBUG: {{ .Values.env.DJANGO_DEBUG | quote }}
ELASTIC_SEARCH_HOST: "elasticsearch://{{ template "ifrcgo-helm.fullname" . }}-elasticsearch:9200" #FIXME: double check format
ELASTIC_SEARCH_HOST: {{ default (printf "elasticsearch://%s-elasticsearch:9200" (include "ifrcgo-helm.fullname" .)) .Values.env.ELASTIC_SEARCH_HOST | quote }}
ELASTIC_SEARCH_INDEX: {{ .Values.env.ELASTIC_SEARCH_INDEX | quote }}
DOCKER_HOST_IP: {{ .Values.env.DOCKER_HOST_IP | quote }}
DJANGO_ADDITIONAL_ALLOWED_HOSTS: {{ .Values.env.DJANGO_ADDITIONAL_ALLOWED_HOSTS | quote }}
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