mirror of
https://github.com/rubenhensen/k8scd.git
synced 2026-09-17 02:12:55 +02:00
99 lines
2.9 KiB
YAML
99 lines
2.9 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "sogo.fullname" . }}
|
|
labels:
|
|
{{- include "sogo.labels" . | nindent 4 }}
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
{{- include "sogo.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
|
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
|
|
- |
|
|
# URL-encode the password for PostgreSQL connection strings
|
|
# This handles special characters like &, ^, etc.
|
|
encoded_pwd=$(echo -n "$POSTGRES_PASSWORD" | awk '
|
|
BEGIN {
|
|
for (i = 0; i < 256; i++) chars[sprintf("%c", i)] = sprintf("%%%02X", i)
|
|
}
|
|
{
|
|
for (i = 1; i <= length($0); i++) {
|
|
c = substr($0, i, 1)
|
|
if (c ~ /[A-Za-z0-9._~-]/) printf "%s", c
|
|
else printf "%s", chars[c]
|
|
}
|
|
}
|
|
')
|
|
# Copy config files and substitute the encoded password
|
|
for file in /config-template/*; do
|
|
filename=$(basename "$file")
|
|
sed "s|\${POSTGRES_PASSWORD}|$encoded_pwd|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 }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
ports:
|
|
- name: http
|
|
containerPort: 80
|
|
protocol: TCP
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: /etc/sogo/sogo.conf.d
|
|
- name: data
|
|
mountPath: /var/spool/sogo
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /SOGo
|
|
port: http
|
|
initialDelaySeconds: 60
|
|
periodSeconds: 30
|
|
timeoutSeconds: 10
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /SOGo
|
|
port: http
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
resources:
|
|
{{- toYaml .Values.resources | nindent 10 }}
|
|
volumes:
|
|
- name: config-template
|
|
configMap:
|
|
name: {{ include "sogo.fullname" . }}-config
|
|
- name: config
|
|
emptyDir: {}
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "sogo.fullname" . }}-data
|