mirror of
https://github.com/GothenburgBitFactory/taskchampion-sync-server.git
synced 2026-07-16 08:24:45 +00:00
Fix secret management
This commit is contained in:
committed by
Dustin J. Mitchell
parent
c857163d85
commit
2f84198600
@ -75,5 +75,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "taskchampion-sync-server.postgres-secret-name" -}}
|
{{- define "taskchampion-sync-server.postgres-secret-name" -}}
|
||||||
|
{{- if .Values.postgres.existingSecret -}}
|
||||||
|
{{- .Values.postgres.existingSecret -}}
|
||||||
|
{{- else -}}
|
||||||
{{- printf "%s-connection" .Release.Name -}}
|
{{- printf "%s-connection" .Release.Name -}}
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@ -31,28 +31,11 @@ spec:
|
|||||||
image: "{{ .Values.postgres.initContainer.image }}"
|
image: "{{ .Values.postgres.initContainer.image }}"
|
||||||
imagePullPolicy: {{ .Values.postgres.initContainer.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.postgres.initContainer.imagePullPolicy }}
|
||||||
env:
|
env:
|
||||||
- name: PGHOST
|
- name: PGURI
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
name: {{ printf "%s-connection" .Release.Name }}
|
||||||
key: host
|
key: connection
|
||||||
- name: PGPORT
|
|
||||||
value: "{{ .Values.postgres.port }}"
|
|
||||||
- name: PGUSER
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
|
||||||
key: username
|
|
||||||
- name: PGPASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
|
||||||
key: password
|
|
||||||
- name: PGDATABASE
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
|
||||||
key: database
|
|
||||||
- name: SCHEMA_URL
|
- name: SCHEMA_URL
|
||||||
value: {{ include "taskchampion-sync-server.schema-url" . | quote }}
|
value: {{ include "taskchampion-sync-server.schema-url" . | quote }}
|
||||||
command:
|
command:
|
||||||
@ -60,7 +43,7 @@ spec:
|
|||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
until pg_isready -h "$PGHOST" -p "$PGPORT" -U "$PGUSER"; do
|
until pg_isready -d "$PGURI"; do
|
||||||
echo 'Waiting for PostgreSQL...'
|
echo 'Waiting for PostgreSQL...'
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
@ -69,7 +52,7 @@ spec:
|
|||||||
echo 'Failed to download schema - continuing with main container'
|
echo 'Failed to download schema - continuing with main container'
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -f /tmp/schema.sql || {
|
psql "$PGURI" -f /tmp/schema.sql || {
|
||||||
echo 'Schema execution failed (SQL error) - continuing with main container'
|
echo 'Schema execution failed (SQL error) - continuing with main container'
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,5 @@ metadata:
|
|||||||
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
host: {{ .Values.postgres.host | b64enc }}
|
|
||||||
port: {{ .Values.postgres.port | toString | b64enc }}
|
|
||||||
username: {{ .Values.postgres.username | b64enc }}
|
|
||||||
password: {{ .Values.postgres.password | b64enc }}
|
|
||||||
database: {{ .Values.postgres.database | b64enc }}
|
|
||||||
connection: {{ include "taskchampion-sync-server.postgres-connection" . | b64enc }}
|
connection: {{ include "taskchampion-sync-server.postgres-connection" . | b64enc }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
Reference in New Issue
Block a user