mirror of
https://github.com/rubenhensen/k8scd.git
synced 2026-09-17 02:12:55 +02:00
Add init container sogo
This commit is contained in:
@@ -49,12 +49,12 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
PostgreSQL connection URL
|
||||
PostgreSQL connection URL base (without table name)
|
||||
*/}}
|
||||
{{- define "sogo.postgresqlURL" -}}
|
||||
{{- $user := .Values.postgresql.username -}}
|
||||
{{- $host := printf "%s-postgres-rw.%s.svc.cluster.local" (include "sogo.fullname" .) .Release.Namespace -}}
|
||||
{{- $port := "5432" -}}
|
||||
{{- $db := .Values.postgresql.database -}}
|
||||
{{- printf "postgresql://%s:${POSTGRES_PASSWORD}@%s:%s/%s?sslmode=require" $user $host $port $db -}}
|
||||
{{- printf "postgresql://%s:${POSTGRES_PASSWORD}@%s:%s/%s" $user $host $port $db -}}
|
||||
{{- end }}
|
||||
|
||||
@@ -18,6 +18,31 @@ spec:
|
||||
labels:
|
||||
{{- include "sogo.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
initContainers:
|
||||
- name: config-init
|
||||
image: busybox:latest
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "sogo.fullname" . }}-postgres-credentials
|
||||
key: password
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
# Copy config files from ConfigMap and substitute environment variables
|
||||
for file in /config-template/*; do
|
||||
filename=$(basename "$file")
|
||||
# Use sed to replace ${POSTGRES_PASSWORD} with actual value
|
||||
sed "s|\${POSTGRES_PASSWORD}|${POSTGRES_PASSWORD}|g" "$file" > "/config/$filename"
|
||||
done
|
||||
echo "Configuration files generated successfully"
|
||||
volumeMounts:
|
||||
- name: config-template
|
||||
mountPath: /config-template
|
||||
- name: config
|
||||
mountPath: /config
|
||||
containers:
|
||||
- name: sogo
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
@@ -26,12 +51,6 @@ spec:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "sogo.fullname" . }}-postgres-credentials
|
||||
key: password
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/sogo/sogo.conf.d
|
||||
@@ -56,9 +75,11 @@ spec:
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
volumes:
|
||||
- name: config
|
||||
- name: config-template
|
||||
configMap:
|
||||
name: {{ include "sogo.fullname" . }}-config
|
||||
- name: config
|
||||
emptyDir: {}
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "sogo.fullname" . }}-data
|
||||
|
||||
Reference in New Issue
Block a user