mirror of
https://github.com/GothenburgBitFactory/taskchampion-sync-server.git
synced 2026-07-16 16:35:41 +00:00
Fix plain connection string in pod env
This commit is contained in:
committed by
Dustin J. Mitchell
parent
eee66c5475
commit
c58bb4800d
@ -41,50 +41,11 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "taskchampion-sync-server.postgres-connection" -}}
|
{{- define "taskchampion-sync-server.postgres-connection" -}}
|
||||||
{{- $secret := .Values.postgres.existingSecret -}}
|
{{- $host := .Values.postgres.host -}}
|
||||||
{{- $secretData := "" -}}
|
{{- $port := .Values.postgres.port | quote -}}
|
||||||
{{- if $secret -}}
|
{{- $username := .Values.postgres.username -}}
|
||||||
{{- $secretData = (lookup "v1" "Secret" .Release.Namespace $secret).data -}}
|
{{- $password := .Values.postgres.password -}}
|
||||||
{{- end -}}
|
{{- $database := .Values.postgres.database -}}
|
||||||
|
|
||||||
{{- $host := "" -}}
|
|
||||||
{{- $port := "5432" -}}
|
|
||||||
{{- $username := "" -}}
|
|
||||||
{{- $password := "" -}}
|
|
||||||
{{- $database := "taskchampion" -}}
|
|
||||||
|
|
||||||
{{- /* Get values from secret (higher priority) */ -}}
|
|
||||||
{{- if $secretData -}}
|
|
||||||
{{- if hasKey $secretData "host" -}}
|
|
||||||
{{- $host = (b64dec $secretData.host) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if hasKey $secretData "port" -}}
|
|
||||||
{{- $port = (b64dec $secretData.port) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if hasKey $secretData "username" -}}
|
|
||||||
{{- $username = (b64dec $secretData.username) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if hasKey $secretData "password" -}}
|
|
||||||
{{- $password = (b64dec $secretData.password) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if hasKey $secretData "database" -}}
|
|
||||||
{{- $database = (b64dec $secretData.database) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- /* Fallback to values.yaml */ -}}
|
|
||||||
{{- if eq $host "" -}}
|
|
||||||
{{- $host = .Values.postgres.host -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if eq $username "" -}}
|
|
||||||
{{- $username = .Values.postgres.username -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if eq $password "" -}}
|
|
||||||
{{- $password = .Values.postgres.password -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if eq $database "" -}}
|
|
||||||
{{- $database = .Values.postgres.database -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- /* Build URI */ -}}
|
{{- /* Build URI */ -}}
|
||||||
{{- $uri := printf "postgresql://" -}}
|
{{- $uri := printf "postgresql://" -}}
|
||||||
@ -104,3 +65,11 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $uri -}}
|
{{- $uri -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "taskchampion-sync-server.postgres-secret-name" -}}
|
||||||
|
{{- if .Values.postgres.existingSecret -}}
|
||||||
|
{{- .Values.postgres.existingSecret -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- include "taskchampion-sync-server.fullname" . -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
@ -18,11 +18,10 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
{{- include "taskchampion-sync-server.selectorLabels" . | nindent 8 }}
|
{{- include "taskchampion-sync-server.selectorLabels" . | nindent 8 }}
|
||||||
spec:
|
spec:
|
||||||
{{- with .Values.image.pullSecrets }}
|
{{- if .Values.serviceAccount.create }}
|
||||||
imagePullSecrets:
|
serviceAccountName: {{ include "taskchampion-sync-server.fullname" . }}
|
||||||
{{- range . }}
|
{{- else if .Values.serviceAccount.name }}
|
||||||
- name: {{ . }}
|
serviceAccountName: {{ .Values.serviceAccount.name }}
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.securityContext | nindent 8 }}
|
{{- toYaml .Values.securityContext | nindent 8 }}
|
||||||
@ -52,7 +51,10 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if eq .Values.postgres.enabled true }}
|
{{- if eq .Values.postgres.enabled true }}
|
||||||
- name: CONNECTION
|
- name: CONNECTION
|
||||||
value: {{ include "taskchampion-sync-server.postgres-connection" . | quote }}
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
||||||
|
key: connection
|
||||||
{{- end }}
|
{{- end }}
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
{{- if and .Values.postgres.enabled (eq .Values.postgres.existingSecret "") -}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
connection: {{ include "taskchampion-sync-server.postgres-connection" . | b64enc }}
|
||||||
|
{{- end -}}
|
||||||
38
helm/taskchampion-sync-server/templates/serviceaccount.yaml
Normal file
38
helm/taskchampion-sync-server/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{{- if .Values.serviceAccount.create -}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
||||||
|
{{- with .Values.serviceAccount.annotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}-secret-manager
|
||||||
|
labels:
|
||||||
|
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["secrets"]
|
||||||
|
verbs: ["create", "get", "update", "patch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}-secret-binding
|
||||||
|
labels:
|
||||||
|
{{- include "taskchampion-sync-server.labels" . | nindent 4 }}
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}-secret-manager
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ include "taskchampion-sync-server.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace }}
|
||||||
|
{{- end -}}
|
||||||
@ -79,10 +79,17 @@ sqlite:
|
|||||||
storageClass: ""
|
storageClass: ""
|
||||||
existingClaim: ""
|
existingClaim: ""
|
||||||
|
|
||||||
# PostgreSQL backend configuration (mutually exclusive with sqlite)
|
# Service account configuration
|
||||||
|
serviceAccount:
|
||||||
|
create: true # Default: automatically create service account
|
||||||
|
name: "" # Optional: use existing service account
|
||||||
|
annotations: {}
|
||||||
|
|
||||||
|
# PostgreSQL configuration
|
||||||
postgres:
|
postgres:
|
||||||
enabled: false
|
enabled: false
|
||||||
existingSecret: ""
|
existingSecret: "" # If empty, auto-create secret; if provided, use existing
|
||||||
|
# Individual connection components for building connection string
|
||||||
database: taskchampion
|
database: taskchampion
|
||||||
host: postgres
|
host: postgres
|
||||||
port: 5432
|
port: 5432
|
||||||
|
|||||||
Reference in New Issue
Block a user