Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

define uri for migrations, create migration job #622

Open
wants to merge 2 commits into
base: master
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
4 changes: 2 additions & 2 deletions charts/konga/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "1.0"
appVersion: "0.14.9"
description: A Helm chart for Kubernetes
name: konga
version: 1.0.0
version: 1.0.1
29 changes: 25 additions & 4 deletions charts/konga/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,47 @@ data:
{{- if .Values.config }}
PORT: "{{ default 1337 .Values.config.port }}"
NODE_ENV: {{ default "development" .Values.config.node_env }}
{{- if not ( empty .Values.config.ssl_key_path ) }}
SSL_KEY_PATH: {{ .Values.config.ssl_key_path }}
{{- end }}
{{- if not ( empty .Values.config.ssl_crt_path )}}
SSL_CRT_PATH: {{ .Values.config.ssl_crt_path }}
{{- end }}
KONGA_HOOK_TIMEOUT: "{{ default 60000 .Values.config.konga_hook_timeout }}"
DB_ADAPTER: {{ default "postgres" .Values.config.db_adapter }}
DB_URI: {{ .Values.config.db_uri }}
DB_HOST: {{ default "localhost" .Values.config.db_host }}
DB_PORT: "{{ default 5432 .Values.config.db_port }}"
{{- if and ( eq .Values.config.db_adapter "postgres" ) ( empty .Values.config.db_uri) }}
{{- $dburi := ( print "postgresql://" .Values.config.db_user ":" .Values.config.db_password "@" ( default "localhost" .Values.config.db_host ) ":" ( default 5432 .Values.config.db_port ) "/" .Values.config.db_database ) }}
DB_URI: {{ $dburi | quote }}
{{- else if and ( eq .Values.config.db_adapter "mysql" ) ( empty .Values.config.db_uri) }}
{{- $dburi := ( print .Values.config.db_adapter "://" .Values.config.db_user ":" .Values.config.db_password "@" ( default "localhost" .Values.config.db_host ) ":" ( default 3306 .Values.config.db_port ) "/" .Values.config.db_database ) }}
DB_URI: {{ $dburi | quote }}
{{- else if and ( eq .Values.config.db_adapter "mongo" ) ( empty .Values.config.db_uri ) }}
{{- $dburi := ( print "mongodb://" .Values.config.db_user ":" .Values.config.db_password "@" ( default "localhost" .Values.config.db_host ) ":" ( default 27017 .Values.config.db_port ) "/" .Values.config.db_database ) }}
DB_URI: {{ $dburi | quote }}
{{- end }}
DB_HOST: {{ .Values.config.db_host }}
DB_PORT: {{ .Values.config.db_port | quote }}
DB_USER: {{ .Values.config.db_user }}
DB_PASSWORD: {{ .Values.config.db_password }}
DB_DATABASE: {{ default "konga_database" .Values.config.db_database }}
{{- if eq .Values.config.db_adapter "postgres" }}
DB_PG_SCHEMA: {{ default "public" .Values.config.db_pg_schema }}
{{- end}}
{{- if eq .Values.config.node_env "development" }}
KONGA_LOG_LEVEL: {{ default "debug" .Values.config.log_level }}
{{ else if eq .Values.config.node_env "production" }}
{{- else if eq .Values.config.node_env "production" }}
KONGA_LOG_LEVEL: {{ default "warn" .Values.config.log_level }}
{{- end }}
{{- if not ( empty .Values.config.token_secret ) }}
TOKEN_SECRET: {{ .Values.config.token_secret }}
{{- end }}
{{- if not ( empty .Values.config.konga_node_data ) }}
KONGA_SEED_KONG_NODE_DATA_SOURCE_FILE: "{{ .Values.config.konga_node_data }}"
{{- end }}
{{- if not ( empty .Values.config.konga_user_data ) }}
KONGA_SEED_USER_DATA_SOURCE_FILE: "{{ .Values.config.konga_user_data }}"
{{- end }}
{{- end }}

{{- if .Values.ldap }}
KONGA_AUTH_PROVIDER: {{ default "local" .Values.ldap.auth_provider }}
Expand Down
6 changes: 4 additions & 2 deletions charts/konga/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ spec:
app.kubernetes.io/name: {{ include "konga.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
volumes:
{{- if .Values.extraVolumes }}
volumes:
{{ toYaml .Values.extraVolumes | indent 8 }}
{{- end }}
containers:
Expand All @@ -42,10 +42,12 @@ spec:
envFrom:
- configMapRef:
name: {{ include "konga.fullname" . }}-config
{{- if .Values.resources }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- end }}
{{- if .Values.extraVolumeMounts }}
volumeMounts:
{{ toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
Expand Down
45 changes: 45 additions & 0 deletions charts/konga/templates/migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if and .Values.runMigrations ( ne .Values.config.db_adapter "mongo" ) }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "konga.name" . }}-migrations
labels:
app: {{ include "konga.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: init-db-migrations
spec:
template:
metadata:
name: {{ include "konga.name" . }}-migrations
labels:
app.kubernetes.io/name: {{ include "konga.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
helm.sh/chart: {{ include "konga.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
containers:
- name: {{ .Chart.Name }}-migrations
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command:
- "/app/start.sh"
args:
- "-c"
- "prepare"
- "a"
{{- if and ( eq .Values.config.db_adapter "postgres" ) ( empty .Values.config.db_uri) }}
{{- $dburi := ( print "postgresql://" .Values.config.db_user ":" .Values.config.db_password "@" ( default "localhost" .Values.config.db_host ) ":" ( default 5432 .Values.config.db_port ) "/" .Values.config.db_database ) }}
- {{ .Values.config.db_adapter | quote }}
- "-u"
- {{ $dburi | quote }}
{{- else if and ( eq .Values.config.db_adapter "mysql" ) ( empty .Values.config.db_uri) }}
{{- $dburi := ( print .Values.config.db_adapter "://" .Values.config.db_user ":" .Values.config.db_password "@" ( default "localhost" .Values.config.db_host ) ":" ( default 3306 .Values.config.db_port ) "/" .Values.config.db_database ) }}
- {{ .Values.config.db_adapter | quote }}
- "-u"
- {{ $dburi | quote }}
{{- end }}
restartPolicy: Never
backoffLimit: 20
{{- end }}
4 changes: 3 additions & 1 deletion charts/konga/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: pantsel/konga
tag: latest
tag: 0.14.9
pullPolicy: IfNotPresent

nameOverride: ""
Expand Down Expand Up @@ -89,3 +89,5 @@ nodeSelector: {}
tolerations: []

affinity: {}

runMigrations: false