119 lines
3.4 KiB
YAML
119 lines
3.4 KiB
YAML
{{- if .Values.postgresql.enabled }}
|
|
{{- $name := printf "%s-postgresql" (include "archify-sync.fullname" .) }}
|
|
{{- $secret := .Values.postgresql.existingSecret | default $name }}
|
|
{{- if not .Values.postgresql.existingSecret }}
|
|
{{- $password := .Values.postgresql.password }}
|
|
{{- if not $password }}
|
|
{{- $existing := lookup "v1" "Secret" .Release.Namespace $name }}
|
|
{{- $password = $existing | dig "data" "password" "" | b64dec | default (randAlphaNum 32) }}
|
|
{{- end }}
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: {{ $name }}
|
|
labels:
|
|
{{- include "archify-sync.labels" . | nindent 4 }}
|
|
annotations:
|
|
helm.sh/resource-policy: keep
|
|
type: Opaque
|
|
stringData:
|
|
password: {{ $password | quote }}
|
|
url: {{ printf "postgres://archify:%s@%s:5432/archify" $password $name | quote }}
|
|
---
|
|
{{- end }}
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ $name }}
|
|
labels:
|
|
{{- include "archify-sync.labels" . | nindent 4 }}
|
|
spec:
|
|
selector:
|
|
{{- include "archify-sync.dbSelector" . | nindent 4 }}
|
|
ports:
|
|
- name: postgres
|
|
port: 5432
|
|
targetPort: postgres
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: {{ $name }}
|
|
labels:
|
|
{{- include "archify-sync.labels" . | nindent 4 }}
|
|
{{- include "archify-sync.dbSelector" . | nindent 4 }}
|
|
spec:
|
|
serviceName: {{ $name }}
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
{{- include "archify-sync.dbSelector" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "archify-sync.labels" . | nindent 8 }}
|
|
{{- include "archify-sync.dbSelector" . | nindent 8 }}
|
|
spec:
|
|
automountServiceAccountToken: false
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 70
|
|
fsGroup: 70
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
containers:
|
|
- name: postgres
|
|
image: {{ .Values.postgresql.image }}
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: [ALL]
|
|
env:
|
|
- name: POSTGRES_DB
|
|
value: archify
|
|
- name: POSTGRES_USER
|
|
value: archify
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $secret }}
|
|
key: password
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
ports:
|
|
- name: postgres
|
|
containerPort: 5432
|
|
readinessProbe:
|
|
exec:
|
|
command: [pg_isready, -U, archify, -d, archify]
|
|
periodSeconds: 5
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/postgresql/data
|
|
- name: run
|
|
mountPath: /var/run/postgresql
|
|
resources:
|
|
{{- toYaml .Values.postgresql.resources | nindent 12 }}
|
|
volumes:
|
|
- name: run
|
|
emptyDir: {}
|
|
{{- with .Values.postgresql.existingClaim }}
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: {{ . }}
|
|
{{- end }}
|
|
{{- if not .Values.postgresql.existingClaim }}
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: data
|
|
spec:
|
|
accessModes: [ReadWriteOnce]
|
|
{{- with .Values.postgresql.storageClass }}
|
|
storageClassName: {{ . }}
|
|
{{- end }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.postgresql.storage }}
|
|
{{- end }}
|
|
{{- end }}
|