Add postgres deployment for element

This commit is contained in:
Magnus Andersson 2024-11-07 10:59:04 +01:00
parent 2a103b0da4
commit e61e7654dc
Signed by: mandersson
GPG key ID: 1F7C896B34B28164
4 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1,75 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: postgres
labels:
k8s-app: postgres
spec:
replicas: 1
selector:
matchLabels:
k8s-app: postgres
template:
metadata:
labels:
k8s-app: postgres
spec:
containers:
- name: postgresql
image: postgres:17.0-bookworm
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-password
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
- name: sharemem
mountPath: /dev/shm
ports:
- containerPort: 5432
name: postgres
protocol: TCP
resources:
requests:
memory: "2Gi"
cpu: "500m"
limits:
memory: "4Gi"
cpu: "2000m"
livenessProbe:
exec:
command:
- /bin/bash
- -c
- exec pg_isready -U postgres -h 127.0.0.1 -p 5432
failureThreshold: 6
initialDelaySeconds: 20
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /bin/bash
- -c
- exec pg_isready -U postgres -h 127.0.0.1 -p 5432
failureThreshold: 6
initialDelaySeconds: 20
periodSeconds: 10
successThreshold: 2
timeoutSeconds: 5
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-pvc
readOnly: false
- emptyDir:
medium: Memory
sizeLimit: 1Gi
name: sharemem

View file

@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: postgres
labels:
usage: postgres-btsystem

View file

@ -0,0 +1,13 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
namespace: postgres
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 20Gi
storageClassName: rook-cephfs

View file

@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: postgres
spec:
selector:
k8s-app: postgres
ports:
- name: postgres
protocol: TCP
port: 5432
targetPort: 5432