2025-09-21 01:23:35 +03:00

79 lines
2.8 KiB
YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "warframe-db.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "warframe-db.name" . }}
spec:
serviceName: {{ include "warframe-db.fullname" . }}-headless
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "warframe-db.name" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "warframe-db.name" . }}
spec:
securityContext:
fsGroup: 999 # postgres user in official image
containers:
- name: postgres
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: postgres
containerPort: {{ .Values.postgres.port }}
env:
- name: POSTGRES_USER
value: {{ .Values.postgres.user | quote }}
- name: POSTGRES_DB
value: {{ .Values.postgres.database | quote }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "warframe-db.fullname" . }}
key: POSTGRES_PASSWORD
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
{{- if .Values.probes.enabled }}
readinessProbe:
exec:
command: ["sh","-c","pg_isready -U $POSTGRES_USER -d $POSTGRES_DB -h 127.0.0.1 -p {{ .Values.postgres.port }}"]
initialDelaySeconds: {{ .Values.probes.initialDelaySeconds }}
periodSeconds: {{ .Values.probes.periodSeconds }}
timeoutSeconds: {{ .Values.probes.timeoutSeconds }}
failureThreshold: {{ .Values.probes.failureThreshold }}
livenessProbe:
exec:
command: ["sh","-c","pg_isready -U $POSTGRES_USER -d $POSTGRES_DB -h 127.0.0.1 -p {{ .Values.postgres.port }}"]
initialDelaySeconds: {{ add .Values.probes.initialDelaySeconds 10 }}
periodSeconds: {{ .Values.probes.periodSeconds }}
timeoutSeconds: {{ .Values.probes.timeoutSeconds }}
failureThreshold: {{ .Values.probes.failureThreshold }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- if .Values.persistence.storageClassName }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}