Skip to content

Commit

Permalink
Fixes: #234 - customInit: Can't find config setting (#235)
Browse files Browse the repository at this point in the history
* Fixes: #234 - customInit: Can't find config setting

* Reorder configmap-init.yaml to match initContainer startup order.
  • Loading branch information
mgruner authored Nov 23, 2023
1 parent 4e2a191 commit db93f42
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion zammad/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: zammad
version: 10.1.0
version: 10.1.1
appVersion: 6.1.0-24
description: Zammad is a web based open source helpdesk/customer support system with many features to manage customer communication via several channels like telephone, facebook, twitter, chat and e-mails.
home: https://zammad.org
Expand Down
32 changes: 16 additions & 16 deletions zammad/templates/configmap-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
data:
{{ if .Values.zammadConfig.elasticsearch.initialisation }}
elasticsearch-init: |-
#!/bin/bash
set -e
bundle exec rails r 'Setting.set("es_url", "{{ .Values.zammadConfig.elasticsearch.schema }}://{{ if .Values.zammadConfig.elasticsearch.enabled }}{{ .Release.Name }}-elasticsearch{{ else }}{{ .Values.zammadConfig.elasticsearch.host }}{{ end }}:{{ .Values.zammadConfig.elasticsearch.port }}")'
ELASTICSEARCH_USER=${ELASTICSEARCH_USER:-{{ .Values.zammadConfig.elasticsearch.user }}}
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASSWORD}" ]; then
bundle exec rails r "Setting.set(\"es_user\", \"${ELASTICSEARCH_USER}\")"
bundle exec rails r "Setting.set(\"es_password\", \"${ELASTICSEARCH_PASSWORD}\")"
fi
{{- if and .Values.zammadConfig.elasticsearch.reindex }}
bundle exec rake zammad:searchindex:rebuild
{{ end }}
echo "elasticsearch init complete :)"
{{ end }}
postgresql-init: |-
#!/bin/bash
set -e
Expand All @@ -37,6 +22,21 @@ data:
echo "${AUTOWIZARD_JSON}" | base64 -d > /opt/zammad/var/auto_wizard.json
fi
{{- with .Values.zammadConfig.initContainers.zammad.customInit }}
{{- toYaml . | nindent 4 }}
{{- . | nindent 4 }}
{{- end }}
echo "zammad init complete :)"
{{ if .Values.zammadConfig.elasticsearch.initialisation }}
elasticsearch-init: |-
#!/bin/bash
set -e
bundle exec rails r 'Setting.set("es_url", "{{ .Values.zammadConfig.elasticsearch.schema }}://{{ if .Values.zammadConfig.elasticsearch.enabled }}{{ .Release.Name }}-elasticsearch{{ else }}{{ .Values.zammadConfig.elasticsearch.host }}{{ end }}:{{ .Values.zammadConfig.elasticsearch.port }}")'
ELASTICSEARCH_USER=${ELASTICSEARCH_USER:-{{ .Values.zammadConfig.elasticsearch.user }}}
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASSWORD}" ]; then
bundle exec rails r "Setting.set(\"es_user\", \"${ELASTICSEARCH_USER}\")"
bundle exec rails r "Setting.set(\"es_password\", \"${ELASTICSEARCH_PASSWORD}\")"
fi
{{- if and .Values.zammadConfig.elasticsearch.reindex }}
bundle exec rake zammad:searchindex:rebuild
{{ end }}
echo "elasticsearch init complete :)"
{{ end }}
38 changes: 22 additions & 16 deletions zammad/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ spec:
- name: {{ template "zammad.fullname" . }}-var
mountPath: /opt/zammad/var
{{- end }}
- name: zammad-init
- name: postgresql-init
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand All @@ -81,36 +81,36 @@ spec:
value: "{{ if .Values.zammadConfig.memcached.enabled }}{{ .Release.Name }}-memcached{{ else }}{{ .Values.zammadConfig.memcached.host }}{{ end }}:{{ .Values.zammadConfig.memcached.port }}"
- name: REDIS_URL
value: "redis://:$(REDIS_PASSWORD)@{{ if .Values.zammadConfig.redis.enabled }}{{ .Release.Name }}-redis-master{{ else }}{{ .Values.zammadConfig.redis.host }}{{ end }}:{{ .Values.zammadConfig.redis.port }}"
{{- if .Values.autoWizard.enabled }}
- name: AUTOWIZARD_JSON
- name: POSTGRESQL_PASS
valueFrom:
secretKeyRef:
name: {{ template "zammad.autowizardSecretName" . }}
key: {{ .Values.secrets.autowizard.secretKey }}
{{- end }}
name: {{ template "zammad.postgresqlSecretName" . }}
key: {{ .Values.secrets.postgresql.secretKey }}
- name: DATABASE_URL
value: "postgres://{{ .Values.zammadConfig.postgresql.user }}:$(POSTGRESQL_PASS)@{{ if .Values.zammadConfig.postgresql.enabled }}{{ .Release.Name }}-postgresql{{ else }}{{ .Values.zammadConfig.postgresql.host }}{{ end }}:{{ .Values.zammadConfig.postgresql.port }}/{{ .Values.zammadConfig.postgresql.db }}"
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 12 }}
{{- toYaml .Values.extraEnv | nindent 12 }}
{{- end }}
{{- with .Values.zammadConfig.initContainers.zammad.resources }}
{{- with .Values.zammadConfig.initContainers.postgresql.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.zammadConfig.initContainers.zammad.securityContext }}
{{- with .Values.zammadConfig.initContainers.postgresql.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ template "zammad.fullname" . }}-init
mountPath: /docker-entrypoint.sh
readOnly: true
subPath: zammad-init
subPath: postgresql-init
- name: {{ template "zammad.fullname" . }}-tmp
mountPath: /opt/zammad/tmp
- name: {{ template "zammad.fullname" . }}-var
mountPath: /opt/zammad/storage
- name: {{ template "zammad.fullname" . }}-var
mountPath: /opt/zammad/var
- name: postgresql-init
- name: zammad-init
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand All @@ -131,23 +131,29 @@ spec:
name: {{ template "zammad.postgresqlSecretName" . }}
key: {{ .Values.secrets.postgresql.secretKey }}
- name: DATABASE_URL
value: "postgres://{{ .Values.zammadConfig.postgresql.user }}:$(POSTGRESQL_PASS)@{{ if .Values.zammadConfig.postgresql.enabled }}{{ .Release.Name }}-postgresql{{ else }}{{ .Values.zammadConfig.postgresql.host }}{{ end }}:{{ .Values.zammadConfig.postgresql.port }}/{{ .Values.zammadConfig.postgresql.db }}"
value: "postgres://{{ .Values.zammadConfig.postgresql.user }}:$(POSTGRESQL_PASS)@{{ if .Values.zammadConfig.postgresql.enabled }}{{ .Release.Name }}-postgresql{{ else }}{{ .Values.zammadConfig.postgresql.host }}{{ end }}:{{ .Values.zammadConfig.postgresql.port }}/{{ .Values.zammadConfig.postgresql.db }}" {{- if .Values.autoWizard.enabled }}
- name: AUTOWIZARD_JSON
valueFrom:
secretKeyRef:
name: {{ template "zammad.autowizardSecretName" . }}
key: {{ .Values.secrets.autowizard.secretKey }}
{{- end }}
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 12 }}
{{- toYaml .Values.extraEnv | nindent 12 }}
{{- end }}
{{- with .Values.zammadConfig.initContainers.postgresql.resources }}
{{- with .Values.zammadConfig.initContainers.zammad.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.zammadConfig.initContainers.postgresql.securityContext }}
{{- with .Values.zammadConfig.initContainers.zammad.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ template "zammad.fullname" . }}-init
mountPath: /docker-entrypoint.sh
readOnly: true
subPath: postgresql-init
subPath: zammad-init
- name: {{ template "zammad.fullname" . }}-tmp
mountPath: /opt/zammad/tmp
- name: {{ template "zammad.fullname" . }}-var
Expand Down

0 comments on commit db93f42

Please sign in to comment.