feat(deploy): add job to run migrations
This commit is contained in:
parent
72bcaf4b32
commit
68436545be
4 changed files with 56 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ deploy:staging:
|
|||
api ./deploy \
|
||||
--values deploy/values.staging.yaml \
|
||||
--set image.tag=$TAG \
|
||||
--set migrations.image.tag=$TAG \
|
||||
--set imageCredentials.username=$REGISTRY_USERNAME \
|
||||
--set imageCredentials.password=$REGISTRY_PASSWORD \
|
||||
--set config.database.url=$DATABASE_URL
|
||||
|
|
|
|||
36
deploy/templates/migration-job.yaml
Normal file
36
deploy/templates/migration-job.yaml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }}
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/component: "database-migrations"
|
||||
batch.kubernetes.io/job-name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }}
|
||||
spec:
|
||||
ttlSecondsAfterFinished: 604800 # 1 week in seconds
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/component: "database-migrations"
|
||||
batch.kubernetes.io/job-name: {{ .Release.Name }}-migrations-{{ now | unixEpoch }}
|
||||
spec:
|
||||
containers:
|
||||
- name: migrations
|
||||
image: "{{ .Values.migrations.image.repository }}:{{ .Values.migrations.image.tag }}"
|
||||
command: ["/usr/local/bin/migrate"]
|
||||
args: ["-path", "/srv/migrations/", "-database", "$MIGRATE_DATABASE_URL", "up"]
|
||||
env:
|
||||
- name: MIGRATE_DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Release.Name }}
|
||||
key: "database_url.txt"
|
||||
{{- with .Values.migrations.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
restartPolicy: Never
|
||||
backoffLimit: 0
|
||||
|
|
@ -9,3 +9,8 @@ replicas: 2
|
|||
image:
|
||||
pullSecrets:
|
||||
- name: mareshq-gitlab-registry
|
||||
|
||||
migrations:
|
||||
image:
|
||||
pullSecrets:
|
||||
- name: mareshq-gitlab-registry
|
||||
|
|
|
|||
|
|
@ -31,3 +31,17 @@ config:
|
|||
port: 8080
|
||||
database:
|
||||
url:
|
||||
|
||||
migrations:
|
||||
image:
|
||||
pullSecrets: []
|
||||
repository: registry.mareshq.com/hq/yggdrasil/migrations
|
||||
tag: latest
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 250m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
|
|
|
|||
Reference in a new issue