forked from github-mirrorer/taskchampion-sync-server
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 }}
|
||||
|
||||
{{- define "taskchampion-sync-server.postgres-connection" -}}
|
||||
{{- $secret := .Values.postgres.existingSecret -}}
|
||||
{{- $secretData := "" -}}
|
||||
{{- if $secret -}}
|
||||
{{- $secretData = (lookup "v1" "Secret" .Release.Namespace $secret).data -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $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 -}}
|
||||
{{- $host := .Values.postgres.host -}}
|
||||
{{- $port := .Values.postgres.port | quote -}}
|
||||
{{- $username := .Values.postgres.username -}}
|
||||
{{- $password := .Values.postgres.password -}}
|
||||
{{- $database := .Values.postgres.database -}}
|
||||
|
||||
{{- /* Build URI */ -}}
|
||||
{{- $uri := printf "postgresql://" -}}
|
||||
@ -104,3 +65,11 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
{{- $uri -}}
|
||||
{{- 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:
|
||||
{{- include "taskchampion-sync-server.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.image.pullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- range . }}
|
||||
- name: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
serviceAccountName: {{ include "taskchampion-sync-server.fullname" . }}
|
||||
{{- else if .Values.serviceAccount.name }}
|
||||
serviceAccountName: {{ .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 8 }}
|
||||
@ -52,7 +51,10 @@ spec:
|
||||
{{- end }}
|
||||
{{- if eq .Values.postgres.enabled true }}
|
||||
- name: CONNECTION
|
||||
value: {{ include "taskchampion-sync-server.postgres-connection" . | quote }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "taskchampion-sync-server.postgres-secret-name" . }}
|
||||
key: connection
|
||||
{{- end }}
|
||||
ports:
|
||||
- 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: ""
|
||||
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:
|
||||
enabled: false
|
||||
existingSecret: ""
|
||||
existingSecret: "" # If empty, auto-create secret; if provided, use existing
|
||||
# Individual connection components for building connection string
|
||||
database: taskchampion
|
||||
host: postgres
|
||||
port: 5432
|
||||
|
||||
Reference in New Issue
Block a user