Skip to content

Commit

Permalink
Merge pull request #59 from bbkz/dev
Browse files Browse the repository at this point in the history
# 0.2.4-rc.1

* support existing database
  * credentials in the `values.yaml`
  * credentials in a existing secret
* minor upgrade postgres
* minor upgrade redis
  • Loading branch information
bbkz authored Feb 22, 2025
2 parents 622cc90 + 9f09d89 commit 043ef50
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 86 deletions.
8 changes: 8 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.2.4

* support existing database
* credentials in the `values.yaml`
* credentials in a existing secret
* minor upgrade postgres
* minor upgrade redis

## 0.2.3

* fix initContainer when flower is not enabled
Expand Down
8 changes: 4 additions & 4 deletions charts/wger/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: postgres
repository: https://groundhog2k.github.io/helm-charts
version: 1.3.1
version: 1.3.5
- name: redis
repository: https://groundhog2k.github.io/helm-charts
version: 1.2.0
digest: sha256:6a2d1e1a702d88285fce9e5dfcf72d4fa78c42a9b255fa77a8264e1df41c065f
generated: "2024-05-05T14:31:11.163945533+02:00"
version: 1.3.3
digest: sha256:d2001f75ff9aa2bbd0e6ec844568d7d4368e9cc73a19fa90af5853d870d436aa
generated: "2025-02-22T12:08:27.390882873+01:00"
6 changes: 3 additions & 3 deletions charts/wger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: v2
version: 0.2.3
version: 0.2.4-rc.1
appVersion: latest
name: wger
description: A Helm chart for wger installation on Kubernetes
Expand All @@ -15,11 +15,11 @@ dependencies:
condition: postgres.enabled
tags:
- groundhog2k
version: 1.3.1
version: 1.3.5
repository: https://groundhog2k.github.io/helm-charts
- name: redis
condition: redis.enabled
tags:
- groundhog2k
version: 1.2.0
version: 1.3.3
repository: https://groundhog2k.github.io/helm-charts
12 changes: 11 additions & 1 deletion charts/wger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ For additional configuration of the Groundhog2k's PostgreSQL and Redis charts, p
| `app.django.secret.name` | Name of the secret | String | `django` |
| `app.django.secret.key` | Key for the `SECRET_KEY` | String | `randAlphaNum 50` |
| `app.django.cache.timeout` | Cache timeout in seconds | String | `1296000` |

| `app.django.existingDatabase.enabled` | Enable existing database, you need to set `postgres.enabled: false` | Boolean | `false` |
| `app.django.existingDatabase.engine` | Set database engine | String | `django.db.backends.postgresql` |
| `app.django.existingDatabase.host` | Database hostname | String | `{{ .Release.Name }}-postgres` |
| `app.django.existingDatabase.port` | Database port | Integer | `postgres.service.port` |
| `app.django.existingDatabase.dbname` | Name of the database | String | `wger` |
| `app.django.existingDatabase.dbuser` | Database User |String | `wger` |
| `app.django.existingDatabase.dbpw` | Database Password | String | `null` |
| `app.django.existingDatabase.existingSecret.name` | Name of a existing secret. If you like to use this for the database credentials | String | `null` |
| `app.django.existingDatabase.existingSecret.dbnameKey` | Key containing the database name | String | `null` |
| `app.django.existingDatabase.existingSecret.dbuserKey` | Key containing the database user | String | `null` |
| `app.django.existingDatabase.existingSecret.dbpwKey` | Key containing the database password | String | `null` |

### Celery

Expand Down
3 changes: 2 additions & 1 deletion charts/wger/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Starting the container may take some time, you can watch the process in the logs
kubectl -n {{ .Release.Namespace }} logs -f -l app.kubernetes.io/name={{ .Release.Name }}-app -c init-container
kubectl -n {{ .Release.Namespace }} logs -f -l app.kubernetes.io/name={{ .Release.Name }}-app -c wger

{{- if not .Values.app.django.existingDatabase.enabled }}
Get the postgres superuser passwords:

kubectl -n {{ .Release.Namespace }} get secret {{ .Release.Name }}-postgres -o jsonpath='{.data.POSTGRES_PASSWORD}' | base64 -d

Get the postgres user passwords:

kubectl -n {{ .Release.Namespace }} get secret {{ .Release.Name }}-postgres -o jsonpath='{.data.USERDB_PASSWORD}' | base64 -d

{{- end }}
70 changes: 67 additions & 3 deletions charts/wger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ environment:
- name: DJANGO_PERFORM_MIGRATIONS
value: "True"
- name: DJANGO_DB_ENGINE
value: "django.db.backends.postgresql"
value: {{ .Values.app.django.existingDatabase.engine | default "django.db.backends.postgresql" | quote }}
- name: DJANGO_DB_HOST
value: "{{ .Release.Name }}-postgres"
value: {{ .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
- name: DJANGO_DB_PORT
value: {{ int .Values.postgres.service.port | quote }}
value: {{ .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
# cache
- name: DJANGO_CACHE_BACKEND
value: "django_redis.cache.RedisCache"
Expand Down Expand Up @@ -169,3 +169,67 @@ environment:
value: {{ .value | quote }}
{{- end }}
{{- end }}
{{/*
database settings
used for wger-app and celery containers
*/}}
{{- define "database.settings" }}
{{- if .Values.app.django.existingDatabase.enabled }}
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: {{ .Values.app.django.existingDatabase.existingSecret.name | default (print .Release.Name "-existing-database") | quote }}
key: {{ .Values.app.django.existingDatabase.existingSecret.dbuserKey | default "USERDB_USER" | quote }}
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.app.django.existingDatabase.existingSecret.name | default (print .Release.Name "-existing-database") | quote }}
key: {{ .Values.app.django.existingDatabase.existingSecret.dbpwKey | default "USERDB_PASSWORD" | quote }}
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: {{ .Values.app.django.existingDatabase.existingSecret.name | default (print .Release.Name "-existing-database") | quote }}
key: {{ .Values.app.django.existingDatabase.existingSecret.dbnameKey | default "USERDB_NAME" | quote }}
{{- else }}
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: {{.Release.Name}}-postgres
key: "USERDB_USER"
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{.Release.Name}}-postgres
key: "USERDB_PASSWORD"
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: {{.Release.Name}}-postgres
key: "POSTGRES_DB"
{{- end }}
{{- end }}
{{/*
initContainer postgres command
used for wger-app and celery containers
*/}}
{{- define "initContainer.pgonly.command" }}
{{- $dbhost := .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
{{- $dbport := .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
- /bin/sh
- -c
- until nc -zvw10 {{ $dbhost }} {{ $dbport }}; do echo "Waiting for postgres service ({{ $dbhost }}:{{ $dbport }}) "; sleep 2; done &&
until nc -zvw10 {{.Release.Name}}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{.Release.Name}}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done
{{- end }}
{{/*
initContainer web command
used for celery containers
*/}}
{{- define "initContainer.web.command" }}
{{- $dbhost := .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
{{- $dbport := .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
- /bin/sh
- -c
- until nc -zvw10 {{ $dbhost }} {{ $dbport }}; do echo "Waiting for postgres service ({{ $dbhost }}:{{ $dbport }}) "; sleep 2; done &&
until nc -zvw10 {{ .Release.Name }}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{ .Release.Name }}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done &&
until wget --spider http://{{ .Release.Name }}-http:8000; do echo "Waiting for wger app service ({{ .Release.Name }}-http:8000)"; sleep 2; done
{{- end }}
81 changes: 7 additions & 74 deletions charts/wger/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
imagePullPolicy: {{ .Values.app.global.image.PullPolicy }}
env:
{{- include "wger.env" . | indent 12 }}
{{- include "database.settings" . | indent 8 }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand All @@ -44,21 +45,6 @@ spec:
secretKeyRef:
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
key: "signing-key"
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_USER"
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_PASSWORD"
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "POSTGRES_DB"
{{- if .Values.app.mail.enabled }}
- name: EMAIL_HOST_PASSWORD
valueFrom:
Expand Down Expand Up @@ -149,10 +135,7 @@ spec:
- name: init-container
image: docker.io/busybox:latest
command:
- /bin/sh
- -c
- until nc -zvw10 {{.Release.Name}}-postgres {{ .Values.postgres.service.port }}; do echo "Waiting for postgres service ({{.Release.Name}}-postgres:{{ .Values.postgres.service.port }}) "; sleep 2; done &&
until nc -zvw10 {{.Release.Name}}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{.Release.Name}}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done
{{- include "initContainer.pgonly.command" . | indent 10 }}
{{- if or (.Values.app.persistence.enabled) (.Values.app.nginx.enabled) }}
volumes:
- name: wger-media
Expand Down Expand Up @@ -217,6 +200,7 @@ spec:
imagePullPolicy: {{ .Values.app.global.image.PullPolicy }}
env:
{{- include "wger.env" . | indent 12 }}
{{- include "database.settings" . | indent 8 }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand All @@ -227,21 +211,6 @@ spec:
secretKeyRef:
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
key: "signing-key"
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_USER"
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_PASSWORD"
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "POSTGRES_DB"
{{- if .Values.app.mail.enabled }}
- name: EMAIL_HOST_PASSWORD
valueFrom:
Expand Down Expand Up @@ -293,6 +262,7 @@ spec:
imagePullPolicy: {{ .Values.app.global.image.PullPolicy }}
env:
{{- include "wger.env" . | indent 12 }}
{{- include "database.settings" . | indent 8 }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand All @@ -303,21 +273,6 @@ spec:
secretKeyRef:
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
key: "signing-key"
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_USER"
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_PASSWORD"
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "POSTGRES_DB"
{{- if .Values.app.mail.enabled }}
- name: EMAIL_HOST_PASSWORD
valueFrom:
Expand Down Expand Up @@ -364,11 +319,7 @@ spec:
- name: init-container
image: docker.io/busybox:latest
command:
- /bin/sh
- -c
- until nc -zvw10 {{ .Release.Name }}-postgres {{ .Values.postgres.service.port }}; do echo "Waiting for postgres service ({{ .Release.Name }}-postgres:{{ .Values.postgres.service.port }}) "; sleep 2; done &&
until nc -zvw10 {{ .Release.Name }}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{ .Release.Name }}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done &&
until wget --spider http://{{ .Release.Name }}-http:8000; do echo "Waiting for wger app service ({{ .Release.Name }}-http:8000)"; sleep 2; done
{{- include "initContainer.web.command" . | indent 10 }}
volumes:
- name: wger-media
persistentVolumeClaim:
Expand Down Expand Up @@ -434,6 +385,7 @@ spec:
imagePullPolicy: {{ .Values.app.global.image.PullPolicy }}
env:
{{- include "wger.env" . | indent 12 }}
{{- include "database.settings" . | indent 8 }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand All @@ -444,21 +396,6 @@ spec:
secretKeyRef:
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
key: "signing-key"
- name: DJANGO_DB_USER
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_USER"
- name: DJANGO_DB_PASSWORD
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "USERDB_PASSWORD"
- name: DJANGO_DB_DATABASE
valueFrom:
secretKeyRef:
name: "{{.Release.Name}}-postgres"
key: "POSTGRES_DB"
{{- if .Values.app.mail.enabled }}
- name: EMAIL_HOST_PASSWORD
valueFrom:
Expand Down Expand Up @@ -508,11 +445,7 @@ spec:
- name: init-container
image: docker.io/busybox:latest
command:
- /bin/sh
- -c
- until nc -zvw10 {{.Release.Name}}-postgres {{ .Values.postgres.service.port }}; do echo "Waiting for postgres service ({{.Release.Name}}-postgres:{{ .Values.postgres.service.port }}) "; sleep 2; done &&
until nc -zvw10 {{.Release.Name}}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{.Release.Name}}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done &&
until wget --spider http://{{.Release.Name}}-http:8000; do echo "Waiting for wger app service ({{.Release.Name}}-http:8000)"; sleep 2; done
{{- include "initContainer.web.command" . | indent 10 }}
volumes:
- name: wger-media
persistentVolumeClaim:
Expand Down
22 changes: 22 additions & 0 deletions charts/wger/templates/secret-existing-database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.app.django.existingDatabase.enabled }}
{{- if not .Values.app.django.existingDatabase.existingSecret.name }}
apiVersion: v1
kind: Secret
metadata:
name: {{.Release.Name}}-existing-database
namespace: {{ .Release.Namespace }}
annotations:
helm.sh/hook: pre-install,pre-upgrade,pre-rollback
helm.sh/hook-weight: "-5"
stringData:
{{- if .Values.app.django.existingDatabase.dbname }}
USERDB_NAME: {{ .Values.app.django.existingDatabase.dbname | quote }}
{{- end }}
{{- if .Values.app.django.existingDatabase.dbuser }}
USERDB_USER: {{ .Values.app.django.existingDatabase.dbuser | quote }}
{{- end }}
{{- if .Values.app.django.existingDatabase.dbpw }}
USERDB_PASSWORD: {{ .Values.app.django.existingDatabase.dbpw | quote }}
{{- end }}
{{- end }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/wger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ app:
cache:
# in seconds - 60*60*24*15, 15 Days
timeout: 1296000
# for existing databases use the following settings
# you need to set `postgres.enabled: false` as well
existingDatabase:
enabled: false
# set DJANGO_DB_ENGINE
engine: null
# set DJANGO_DB_HOST
host: null
# set DJANGO_DB_PORT
port: null
# set DJANGO_DB_DATABASE
dbname: wger
# set DJANGO_DB_USER
dbuser: wger
# set DJANGO_DB_PASSWORD
dbpw: null
# existing secret key containing database credentials
existingSecret:
# name of the secret
name: null
# overrides app.django.existingDatabase.dbname
dbnameKey: null
# overrides app.django.existingDatabase.dbuser
dbuserKey: null
# overrides app.django.existingDatabase.dbpw
dbpwKey: null

#
# JWT auth
jwt:
Expand Down Expand Up @@ -185,6 +212,7 @@ redis:
# one upon first installation
# password: XXXXXXXXXXXXXXXXXX
# Uncomment the following to enable password authentication:
#
# # Additional environment variables (Redis server and Sentinel)
# env:
# - name: REDIS_PASSWORD
Expand Down

0 comments on commit 043ef50

Please sign in to comment.