move to postgresql

This commit is contained in:
2026-03-26 10:27:07 -03:00
parent c9ba9e4f5f
commit a85722f96a
20 changed files with 800 additions and 234 deletions

View File

@@ -37,7 +37,8 @@ docker_build(
k8s_resource('redis')
k8s_resource('minio', port_forwards=['9000:9000', '9001:9001'])
k8s_resource('fastapi', resource_deps=['redis', 'minio'])
k8s_resource('postgres')
k8s_resource('fastapi', resource_deps=['redis', 'minio', 'postgres'])
k8s_resource('detection-ui')
k8s_resource('gateway', resource_deps=['fastapi', 'detection-ui'],
port_forwards=['8080:8080'])
@@ -45,6 +46,6 @@ k8s_resource('gateway', resource_deps=['fastapi', 'detection-ui'],
# Group uncategorized resources (configmaps, namespace) under infra
k8s_resource(
objects=['mpr:namespace', 'mpr-config:configmap', 'minio-config:configmap',
'envoy-gateway-config:configmap'],
'postgres-config:configmap', 'envoy-gateway-config:configmap'],
new_name='infra',
)

View File

@@ -24,6 +24,8 @@ spec:
name: mpr-config
- configMapRef:
name: minio-config
- configMapRef:
name: postgres-config
readinessProbe:
httpGet:
path: /health

View File

@@ -8,6 +8,7 @@ resources:
- configmap.yaml
- redis.yaml
- minio.yaml
- postgres.yaml
- fastapi.yaml
- detection-ui.yaml
- gateway.yaml

View File

@@ -0,0 +1,63 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
namespace: mpr
data:
POSTGRES_DB: mpr
POSTGRES_USER: mpr
POSTGRES_PASSWORD: mpr
DATABASE_URL: postgresql://mpr:mpr@postgres:5432/mpr
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: mpr
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:16-alpine
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-config
readinessProbe:
exec:
command: ["pg_isready", "-U", "mpr"]
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
memory: 128Mi
cpu: 100m
limits:
memory: 512Mi
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: mpr
spec:
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432