Skip to content

Commit

Permalink
Merge pull request #78 from charlesoconor/feature/DE-3-add-migration-job
Browse files Browse the repository at this point in the history
Add Migration job in Helm Hook
  • Loading branch information
GeorgeMac authored Jul 19, 2023
2 parents 8ddd011 + 244b09d commit 3b9abcc
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/flipt/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: flipt
home: https://flipt.io
description: Flipt is an open source, self-hosted feature flag solution.
type: application
version: 0.35.2
version: 0.36.0
appVersion: v1.23.3
maintainers:
- name: Flipt
Expand Down
10 changes: 9 additions & 1 deletion charts/flipt/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Create a fully qualified name for the migration job
*/}}
{{- define "flipt.migration_name" -}}
{{- include "flipt.fullname" . | trunc 53 | trimSuffix "-" }}-migration
{{- end }}


{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -95,7 +103,7 @@ Return the proper Storage Class
{{- end -}}

{{/*
Pod annotations
Pod annotations
*/}}
{{- define "common.classes.podAnnotations" -}}
{{- if .Values.podAnnotations -}}
Expand Down
3 changes: 3 additions & 0 deletions charts/flipt/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "flipt.fullname" . }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-1"
labels:
{{- include "flipt.labels" . | nindent 4 }}
data:
Expand Down
69 changes: 69 additions & 0 deletions charts/flipt/templates/migration_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{- if (.Values.migration).enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "flipt.migration_name" . }}
labels:
{{- include "flipt.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
activeDeadlineSeconds: {{ .Values.migration.deadLine }}
backoffLimit: 0
template:
metadata:
annotations: {{- include "common.classes.podAnnotations" . | nindent 8 }}
labels:
{{- include "flipt.selectorLabels" . | nindent 8 }}
spec:
restartPolicy: Never
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "flipt.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- "./flipt"
- "migrate"
env:
- name: FLIPT_META_STATE_DIRECTORY
value: /home/flipt/.config/flipt
{{- if .Values.flipt.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.flipt.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: flipt-config
mountPath: /etc/flipt/config/default.yml
readOnly: true
subPath: default.yml
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: flipt-local-state
emptyDir: {}
- name: flipt-config
configMap:
name: {{ include "flipt.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end -}}
8 changes: 8 additions & 0 deletions charts/flipt/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ flipt:
host: localhost
port: 6831

migration:
# If enabled will run the migration script over your db before rolling out
# a new deployment. This will run in a helm hook so will get cleaned up on
# success.
enabled: false
# How long to let the job run for kube will terminate it.
deadLine: 600 # sec

metrics:
serviceMonitor:
# -- If enabled, ServiceMonitor resources for Prometheus Operator are created
Expand Down

0 comments on commit 3b9abcc

Please sign in to comment.