Skip to content

Commit

Permalink
helm chart and docker add db envs (#46)
Browse files Browse the repository at this point in the history
* rework database env docker + add db env to helm chart

* add host envs and template secret name
  • Loading branch information
jeanmi151 authored Feb 17, 2025
1 parent 83ef73f commit b8a7347
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .envs-database
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PGHOST=database
PGPORT=5432
PGDATABASE=georchestra
PGUSER=georchestra
PGPASSWORD=georchestra

POSTGRES_USER=${PGUSER}
POSTGRES_PASSWORD=${PGPASSWORD}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,6 @@ cython_debug/

# PyPI configuration file
.pypirc

# Custom for this repo
.envs-database
17 changes: 4 additions & 13 deletions docker-compose-solo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ volumes:
services:
database:
image: postgres:16
environment:
- PGHOST=database
- PGPORT=5432
- PGDATABASE=georchestra
- PGUSER=georchestra
- PGPASSWORD=georchestra
- POSTGRES_USER=georchestra
- POSTGRES_PASSWORD=georchestra
env_file:
- .envs-database
ports:
- "5432:5432"
volumes:
Expand Down Expand Up @@ -48,16 +42,13 @@ services:
volumes:
- ./backend:/app
- ./config/:/etc/maelstro/:ro
env_file:
- .envs-database
environment:
MAELSTRO_CONFIG: /etc/maelstro/config.yaml
LOCAL_LOGIN: "testadmin"
LOCAL_PASSWORD: "testadmin"
DEMO_CRD: "test12"
PGHOST: "database"
PGPORT: "5432"
PGDATABASE: "georchestra"
PGUSER: "georchestra"
PGPASSWORD: "georchestra"
command:
- serve_docker_dev

Expand Down
50 changes: 50 additions & 0 deletions helm/templates/_bootstrap-maelstro-configuration.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,53 @@
name: ssh-secret
{{- end }}
{{- end -}}

{{/*
Insert database environment variables
*/}}
{{- define "maelstro.bootstrap_maelstro_database_envs" -}}
{{- if .Values.database.auth.existingSecret }}
{{- $secret_name := .Values.database.auth.existingSecret -}}
- name: PGHOST
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: host
optional: false
- name: PGPORT
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: port
optional: false
- name: PGDATABASE
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: dbname
optional: false
- name: PGUSER
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: user
optional: false
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: password
optional: false
{{- else }}
- name: PGHOST
value: {{ .Values.database.auth.host }}
- name: PGPORT
value: {{ .Values.database.auth.port }}
- name: PGDATABASE
value: {{ .Values.database.auth.database }}
- name: PGUSER
value: {{ .Values.database.auth.username }}
- name: PGPASSWORD
value: {{ .Values.database.auth.password }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions helm/templates/maelstro-backend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ spec:
env:
- name: MAELSTRO_CONFIG
value: "/etc/georchestra/maelstro/config.yaml"
{{- include "maelstro.bootstrap_maelstro_database_envs" . | nindent 12 }}
{{- range .Values.credentials }}
- name: {{ .name }}_USERNAME
valueFrom:
Expand Down
2 changes: 2 additions & 0 deletions helm/templates/maelstro-frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ spec:
env:
- name: CUSTOM_SCRIPTS_DIRECTORY
value: "/etc/georchestra/maelstro/scripts"
- name: MAELSTRO_BACK_HOST
value: "{{ include "helm-maelstro.fullname" . }}-maelstro-backend-svc"
{{- with .Values.maelstro_frontend.extra_environment }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/maelstro-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
name: maelstro-creds-ext-plateform-secret
name: {{ include "helm-maelstro.fullname" . }}-creds-ext-plateform-secret
labels:
{{- include "helm-maelstro.labels" . | nindent 4 }}
type: Opaque
Expand Down
19 changes: 16 additions & 3 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ maelstro_frontend:
enabled: true
replicaCount: 1
image:
repository: test
repository: georchestra/maelstro-frontend
tag: latest
tolerations: []
affinity: {}
extra_environment: []
Expand All @@ -21,7 +22,8 @@ maelstro_backend:
enabled: true
replicaCount: 1
image:
repository: test
repository: georchestra/maelstro-backend
tag: latest
tolerations: []
affinity: {}
extra_environment: []
Expand Down Expand Up @@ -52,4 +54,15 @@ datadir:
emptyDir: {}
git:
url: https://github.com/georchestra/datadir.git
ref: docker-master
ref: docker-master

database:
auth:
database: georchestra
host: georchestra
port: "5432"
username: georchestra
password: georchestra
# here specify the name of the secret to use
# existingSecret: mysecret

0 comments on commit b8a7347

Please sign in to comment.