2026-01-13 17:53:04 -03:00
|
|
|
# infrastructure/postgres/statefulset.yaml
|
2026-01-02 01:12:35 -03:00
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: StatefulSet
|
|
|
|
|
metadata:
|
|
|
|
|
name: postgres
|
|
|
|
|
namespace: postgres
|
|
|
|
|
labels:
|
|
|
|
|
app: postgres
|
|
|
|
|
spec:
|
|
|
|
|
serviceName: postgres-service
|
|
|
|
|
replicas: 1
|
|
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app: postgres
|
|
|
|
|
persistentVolumeClaimRetentionPolicy:
|
|
|
|
|
whenDeleted: Retain
|
|
|
|
|
whenScaled: Retain
|
|
|
|
|
updateStrategy:
|
|
|
|
|
type: RollingUpdate
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: postgres
|
|
|
|
|
spec:
|
2026-01-13 12:35:59 -03:00
|
|
|
serviceAccountName: postgres-vault
|
2026-01-02 01:12:35 -03:00
|
|
|
nodeSelector:
|
|
|
|
|
node-role.kubernetes.io/worker: "true"
|
2026-10-03 01:23:30 -05:00
|
|
|
tolerations:
|
|
|
|
|
- key: atlas.bstein.dev/spillover
|
|
|
|
|
operator: Equal
|
|
|
|
|
value: "true"
|
|
|
|
|
effect: PreferNoSchedule
|
|
|
|
|
- key: longhorn
|
|
|
|
|
operator: Equal
|
|
|
|
|
value: "true"
|
|
|
|
|
effect: PreferNoSchedule
|
2026-01-02 01:12:35 -03:00
|
|
|
affinity:
|
|
|
|
|
nodeAffinity:
|
|
|
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
|
|
|
nodeSelectorTerms:
|
|
|
|
|
- matchExpressions:
|
|
|
|
|
- key: node-role.kubernetes.io/worker
|
|
|
|
|
operator: In
|
|
|
|
|
values: ["true"]
|
|
|
|
|
- key: hardware
|
|
|
|
|
operator: In
|
2026-10-03 01:23:30 -05:00
|
|
|
values: ["rpi5", "rpi4"]
|
2026-05-10 04:00:57 -03:00
|
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
|
|
|
- weight: 100
|
|
|
|
|
preference:
|
|
|
|
|
matchExpressions:
|
2026-10-03 01:23:30 -05:00
|
|
|
- key: hardware
|
|
|
|
|
operator: In
|
|
|
|
|
values: ["rpi5"]
|
|
|
|
|
- weight: 50
|
|
|
|
|
preference:
|
|
|
|
|
matchExpressions:
|
|
|
|
|
- key: hardware
|
2026-05-10 04:00:57 -03:00
|
|
|
operator: In
|
2026-10-03 01:23:30 -05:00
|
|
|
values: ["rpi4"]
|
2026-01-02 01:12:35 -03:00
|
|
|
containers:
|
|
|
|
|
- name: postgres
|
2026-10-03 01:23:30 -05:00
|
|
|
image: postgres:15@sha256:6eb0add3b77c081df18aa518ce43df58fdcc40f2e6d868a6fd08038dc7acd425
|
2026-01-02 01:12:35 -03:00
|
|
|
ports:
|
|
|
|
|
- name: postgres
|
|
|
|
|
containerPort: 5432
|
|
|
|
|
protocol: TCP
|
2026-10-03 01:23:30 -05:00
|
|
|
# The namespace's 512 MiB default previously killed backend processes.
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 250m
|
|
|
|
|
memory: 1Gi
|
|
|
|
|
limits:
|
|
|
|
|
cpu: "2"
|
|
|
|
|
memory: 2Gi
|
|
|
|
|
startupProbe:
|
|
|
|
|
exec:
|
|
|
|
|
command: [pg_isready, -U, postgres, -d, postgres]
|
|
|
|
|
periodSeconds: 10
|
|
|
|
|
timeoutSeconds: 5
|
|
|
|
|
failureThreshold: 60
|
|
|
|
|
readinessProbe:
|
|
|
|
|
exec:
|
|
|
|
|
command: [pg_isready, -U, postgres, -d, postgres]
|
|
|
|
|
periodSeconds: 15
|
|
|
|
|
timeoutSeconds: 5
|
|
|
|
|
failureThreshold: 3
|
2026-01-02 01:12:35 -03:00
|
|
|
env:
|
|
|
|
|
- name: PGDATA
|
|
|
|
|
value: /var/lib/postgresql/data/pgdata
|
|
|
|
|
- name: POSTGRES_USER
|
|
|
|
|
value: postgres
|
2026-01-13 12:35:59 -03:00
|
|
|
- name: POSTGRES_PASSWORD_FILE
|
|
|
|
|
value: /mnt/vault/postgres_password
|
2026-01-02 01:12:35 -03:00
|
|
|
- name: POSTGRES_DB
|
|
|
|
|
value: postgres
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: postgres-data
|
|
|
|
|
mountPath: /var/lib/postgresql/data
|
2026-01-13 12:35:59 -03:00
|
|
|
- name: vault-secrets
|
|
|
|
|
mountPath: /mnt/vault
|
|
|
|
|
readOnly: true
|
2026-01-22 18:23:17 -03:00
|
|
|
- name: postgres-exporter
|
2026-10-03 01:23:30 -05:00
|
|
|
image: quay.io/prometheuscommunity/postgres-exporter:v0.15.0@sha256:386b12d19eab2a37d7cd8ca8b4c7491cc7a830d9581f49af6c98a393da9605e6
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 20m
|
|
|
|
|
memory: 64Mi
|
|
|
|
|
limits:
|
|
|
|
|
cpu: 200m
|
|
|
|
|
memory: 128Mi
|
2026-01-22 18:23:17 -03:00
|
|
|
ports:
|
|
|
|
|
- name: metrics
|
|
|
|
|
containerPort: 9187
|
|
|
|
|
protocol: TCP
|
|
|
|
|
env:
|
|
|
|
|
- name: DATA_SOURCE_URI
|
|
|
|
|
value: "localhost:5432/postgres?sslmode=disable"
|
|
|
|
|
- name: DATA_SOURCE_USER
|
|
|
|
|
value: postgres
|
|
|
|
|
- name: DATA_SOURCE_PASS_FILE
|
|
|
|
|
value: /mnt/vault/postgres_password
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: vault-secrets
|
|
|
|
|
mountPath: /mnt/vault
|
|
|
|
|
readOnly: true
|
2026-01-13 12:35:59 -03:00
|
|
|
volumes:
|
|
|
|
|
- name: vault-secrets
|
|
|
|
|
csi:
|
|
|
|
|
driver: secrets-store.csi.k8s.io
|
|
|
|
|
readOnly: true
|
|
|
|
|
volumeAttributes:
|
|
|
|
|
secretProviderClass: postgres-vault
|
2026-01-02 01:12:35 -03:00
|
|
|
volumeClaimTemplates:
|
|
|
|
|
- metadata:
|
|
|
|
|
name: postgres-data
|
|
|
|
|
spec:
|
|
|
|
|
accessModes: ["ReadWriteOnce"]
|
|
|
|
|
storageClassName: astreae
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
storage: 100Gi
|