Skip to content

Commit

Permalink
Centralize job hash generation and incorporate chart version in it (#30)
Browse files Browse the repository at this point in the history
refactor: centralize job hash generation and incorporate chart version in it
  • Loading branch information
echozio authored May 28, 2024
1 parent 58090a8 commit ef1bb9b
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
7 changes: 7 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ app.kubernetes.io/name: {{ include "jitsu.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Hash, used as a unique label for the Chart version + value set
*/}}
{{- define "jitsu.hash" -}}
{{- sha1sum (printf "%s%s" (toJson .Values) (.Chart.Version)) | substr 0 8 -}}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
4 changes: 2 additions & 2 deletions templates/bulker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.clickhouse.enabled }}
- name: wait-for-clickhouse
Expand Down Expand Up @@ -80,7 +80,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.console.enabled }}
- name: wait-for-console
Expand Down
4 changes: 2 additions & 2 deletions templates/console/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.clickhouse.enabled }}
- name: wait-for-clickhouse
Expand All @@ -62,7 +62,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ include "jitsu.hash" . }}"]
{{- end }}
containers:
- name: {{ .Chart.Name }}
Expand Down
4 changes: 2 additions & 2 deletions templates/event-log-init/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "jitsu.fullname" . }}-event-log-init-{{ sha1sum (toJson .Values) | substr 0 8 }}
name: {{ include "jitsu.fullname" . }}-event-log-init-{{ include "jitsu.hash" . }}
labels:
{{- include "jitsu.labels" . | nindent 4 }}
{{- with .Values.eventLogInit.jobAnnotations }}
Expand Down Expand Up @@ -38,7 +38,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.console.enabled }}
- name: wait-for-console
Expand Down
4 changes: 2 additions & 2 deletions templates/event-log-trim/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "jitsu.fullname" . }}-event-log-trim-{{ sha1sum (toJson .Values) | substr 0 8 }}
name: {{ include "jitsu.fullname" . }}-event-log-trim
labels:
{{- include "jitsu.labels" . | nindent 4 }}
{{- with .Values.eventLogTrim.jobAnnotations }}
Expand Down Expand Up @@ -41,7 +41,7 @@ spec:
{{- toYaml . | nindent 16 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.console.enabled }}
- name: wait-for-console
Expand Down
2 changes: 1 addition & 1 deletion templates/ingest/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if .Values.tokenGenerator.enabled }}
- name: wait-for-tokens
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.clickhouse.enabled }}
- name: wait-for-clickhouse
Expand Down
4 changes: 2 additions & 2 deletions templates/migration/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "jitsu.fullname" . }}-migration-{{ sha1sum (toJson .Values) | substr 0 8 }}
name: {{ include "jitsu.fullname" . }}-migration-{{ include "jitsu.hash" . }}
labels:
{{- include "jitsu.labels" . | nindent 4 }}
{{- with .Values.migration.jobAnnotations }}
Expand Down Expand Up @@ -38,7 +38,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.postgresql.enabled }}
- name: wait-for-postgresql
Expand Down
2 changes: 1 addition & 1 deletion templates/rotor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.clickhouse.enabled }}
- name: wait-for-clickhouse
Expand Down
4 changes: 2 additions & 2 deletions templates/syncctl/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}"]
{{- end }}
{{- if .Values.migration.enabled }}
- name: wait-for-migration
Expand All @@ -53,7 +53,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
image: ghcr.io/groundnuty/k8s-wait-for:v2.0
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ sha1sum (toJson .Values) | substr 0 8 }}"]
args: ["job-wr", "{{ include "jitsu.fullname" . }}-migration-{{ include "jitsu.hash" . }}"]
{{- end }}
containers:
- name: {{ .Chart.Name }}
Expand Down
2 changes: 1 addition & 1 deletion templates/token-generator/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}
name: {{ include "jitsu.fullname" . }}-token-generator-{{ include "jitsu.hash" . }}
labels:
{{- include "jitsu.labels" . | nindent 4 }}
{{- with .Values.tokenGenerator.jobAnnotations }}
Expand Down

0 comments on commit ef1bb9b

Please sign in to comment.