Verified Commit a1ecf472 authored by Hugo's avatar Hugo
Browse files

add autoMigrateDomain

parent 726854e5
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ tpl .Values.fqdn . }}-file
data:
config.json: |-
{
"production": {
"use_env_variable": "CMD_DB_URL",
"dialect": "postgres",
"protocol": "postgres",
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
},
"db": {
"dialect": "postgres",
"protocol": "postgres",
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
}
}
}
}
.sequelizerc: |-
var path = require('path');
module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models')
}
......@@ -17,6 +17,10 @@ spec:
app.kubernetes.io/part-of: hedgedoc
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/configfile: {{ include (print $.Template.BasePath "/configfile.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
labels:
app.kubernetes.io/component: app
app.kubernetes.io/instance: {{ tpl .Values.fqdn . }}
......@@ -24,6 +28,9 @@ spec:
app.kubernetes.io/part-of: hedgedoc
spec:
volumes:
- name: config
configMap:
name: {{ tpl .Values.fqdn . }}-file
containers:
- env:
- name: CMD_MINIO_ACCESS_KEY
......@@ -53,10 +60,17 @@ spec:
name: {{ template "configName" . }}
- secretRef:
name: {{ template "secretName" . }}
volumeMounts:
- mountPath: /files
name: config
- mountPath: /hedgedoc/.sequelizerc
name: config
subPath: .sequelizerc
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
name: hedgedoc
ports:
- containerPort: 3000
name: http
protocol: TCP
\ No newline at end of file
protocol: TCP
\ No newline at end of file
{{ $config := lookup "v1" "ConfigMap" .Release.Namespace (include "configName" .) }}
{{- if and .Values.autoMigrateDomain $config.data }}
{{ $oldDomain := $config.data.CMD_DOMAIN }}
{{ $newDomain := (tpl .Values.domain .) }}
{{- if ne $oldDomain $newDomain }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ tpl .Values.fqdn . }}-migrate-domain
spec:
template:
spec:
containers:
- name: postgres
image: postgres:12
command:
- psql
- -c
- UPDATE "Notes" SET content = replace(content, '{{ $oldDomain }}', '{{ $newDomain }}');
env:
- name: PGHOST
value: pg-{{ .Release.Namespace }}
- name: PGDATABASE
value: hedgedoc
- name: PGPORT
value: "5432"
- name: PGUSER
valueFrom:
secretKeyRef:
key: username
name: "hedgedoc.pg-{{ .Release.Namespace }}{{ .Values.pgCredentialsSuffix }}"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
key: password
name: "hedgedoc.pg-{{ .Release.Namespace }}{{ .Values.pgCredentialsSuffix }}"
restartPolicy: Never
backoffLimit: 3
ttlSecondsAfterFinished: 120
{{- end }}
{{- end }}
\ No newline at end of file
......@@ -20,3 +20,4 @@ oauth:
email: email
pgCredentialsSuffix: ".credentials"
autoMigrateDomain: true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment