Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move credentials to Secret #29

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
2 changes: 1 addition & 1 deletion charts/traccar/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: traccar
description: A Helm chart for Traccar GPS Server
type: application
version: 1.7.1
version: 1.8.0
appVersion: "5.10"
dependencies:
- name: mysql
Expand Down
15 changes: 1 addition & 14 deletions charts/traccar/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data:
<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<entry key='config.default'>./conf/default.xml</entry>
<entry key='config.useEnvironmentVariables'>true</entry>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tananaev by adding this configuration in the xml file, is it possible to use environment variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.


{{- if .Values.traccar.server }}
{{- if .Values.traccar.server.statistics }}
Expand Down Expand Up @@ -155,8 +156,6 @@ data:
{{- if .Values.mysql.enabled }}
<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://{{ include "traccar.fullname" . }}-mysql:3306/{{ .Values.mysql.auth.database }}?serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
<entry key='database.user'>{{ .Values.mysql.auth.username }}</entry>
<entry key='database.password'>{{ .Values.mysql.auth.password }}</entry>
{{- else }}
{{- if .Values.traccar.database.driverFile }}
<entry key='database.driverFile'>{{ .Values.traccar.database.driverFile }}</entry>
Expand All @@ -167,12 +166,6 @@ data:
{{- if .Values.traccar.database.url }}
<entry key='database.url'>{{ .Values.traccar.database.url }}</entry>
{{- end }}
{{- if .Values.traccar.database.user }}
<entry key='database.user'>{{ .Values.traccar.database.user }}</entry>
{{- end }}
{{- if .Values.traccar.database.password }}
<entry key='database.password'>{{ .Values.traccar.database.password }}</entry>
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.traccar.database }}
Expand Down Expand Up @@ -311,12 +304,6 @@ data:
{{- if .Values.traccar.mail.smtp.fromName }}
<entry key='mail.smtp.fromName'>{{ .Values.traccar.mail.smtp.fromName }}</entry>
{{- end }}
{{- if .Values.traccar.mail.smtp.username }}
<entry key='mail.smtp.username'>{{ .Values.traccar.mail.smtp.username }}</entry>
{{- end }}
{{- if .Values.traccar.mail.smtp.password }}
<entry key='mail.smtp.password'>{{ .Values.traccar.mail.smtp.password }}</entry>
{{- end }}
{{- end }}
{{- end }}

Expand Down
8 changes: 8 additions & 0 deletions charts/traccar/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- if not .Values.configOverride }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -89,6 +92,11 @@ spec:
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if not .Values.configOverride }}
envFrom:
- secretRef:
name: {{ include "traccar.fullname" . }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
Expand Down
26 changes: 26 additions & 0 deletions charts/traccar/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if not .Values.configOverride }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "traccar.fullname" . }}
labels:
{{- include "traccar.labels" . | nindent 4 }}
stringData:
{{- if .Values.mysql.enabled }}
DATABASE_USER: {{ .Values.mysql.auth.username | quote }}
DATABASE_PASSWORD: {{ .Values.mysql.auth.password | quote }}
{{- else }}
{{- if ((.Values.traccar).database).user }}
DATABASE_USER: {{ .Values.traccar.database.user | quote }}
{{- end }}
{{- if ((.Values.traccar).database).password }}
DATABASE_PASSWORD: {{ .Values.traccar.database.password | quote }}
{{- end }}
{{- end }} {{/* end if mysql.enabled */}}
{{- if (((.Values.traccar).mail).smtp).username }}
MAIL_SMTP_USERNAME: {{ .Values.traccar.mail.smtp.username | quote }}
{{- end }}
{{- if (((.Values.traccar).mail).smtp).password }}
MAIL_SMTP_PASSWORD: {{ .Values.traccar.mail.smtp.password | quote }}
{{- end }}
{{- end }}
Loading