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 }}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
PostgreSQL connection URL
|
PostgreSQL connection URL base (without table name)
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "sogo.postgresqlURL" -}}
|
{{- define "sogo.postgresqlURL" -}}
|
||||||
{{- $user := .Values.postgresql.username -}}
|
{{- $user := .Values.postgresql.username -}}
|
||||||
{{- $host := printf "%s-postgres-rw.%s.svc.cluster.local" (include "sogo.fullname" .) .Release.Namespace -}}
|
{{- $host := printf "%s-postgres-rw.%s.svc.cluster.local" (include "sogo.fullname" .) .Release.Namespace -}}
|
||||||
{{- $port := "5432" -}}
|
{{- $port := "5432" -}}
|
||||||
{{- $db := .Values.postgresql.database -}}
|
{{- $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 }}
|
{{- end }}
|
||||||
|
|||||||
@@ -18,6 +18,31 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
{{- include "sogo.selectorLabels" . | nindent 8 }}
|
{{- include "sogo.selectorLabels" . | nindent 8 }}
|
||||||
spec:
|
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:
|
containers:
|
||||||
- name: sogo
|
- name: sogo
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
@@ -26,12 +51,6 @@ spec:
|
|||||||
- name: http
|
- name: http
|
||||||
containerPort: 80
|
containerPort: 80
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
env:
|
|
||||||
- name: POSTGRES_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: {{ include "sogo.fullname" . }}-postgres-credentials
|
|
||||||
key: password
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /etc/sogo/sogo.conf.d
|
mountPath: /etc/sogo/sogo.conf.d
|
||||||
@@ -56,9 +75,11 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources | nindent 10 }}
|
{{- toYaml .Values.resources | nindent 10 }}
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config-template
|
||||||
configMap:
|
configMap:
|
||||||
name: {{ include "sogo.fullname" . }}-config
|
name: {{ include "sogo.fullname" . }}-config
|
||||||
|
- name: config
|
||||||
|
emptyDir: {}
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: {{ include "sogo.fullname" . }}-data
|
claimName: {{ include "sogo.fullname" . }}-data
|
||||||
|
|||||||
Reference in New Issue
Block a user