116 lines
2.5 KiB
YAML
116 lines
2.5 KiB
YAML
# PersistentVolume – host-path volume for PostgreSQL data
|
||
|
||
apiVersion: v1
|
||
kind: PersistentVolume
|
||
metadata:
|
||
name: vigimeteo-db-pv
|
||
namespace: vigimeteo
|
||
labels:
|
||
app: vigimeteo-db
|
||
spec:
|
||
capacity:
|
||
storage: 1Gi
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
persistentVolumeReclaimPolicy: Retain
|
||
storageClassName: manual
|
||
hostPath:
|
||
path: /home/cytech/vigimeteo-db-data
|
||
|
||
---
|
||
|
||
# PersistentVolumeClaim – claimed by the StatefulSet below
|
||
|
||
apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
metadata:
|
||
name: vigimeteo-db-pvc
|
||
namespace: vigimeteo
|
||
labels:
|
||
app: vigimeteo-db
|
||
spec:
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
storageClassName: manual
|
||
resources:
|
||
requests:
|
||
storage: 1Gi
|
||
|
||
---
|
||
|
||
# StatefulSet – single PostgreSQL replica
|
||
|
||
apiVersion: apps/v1
|
||
kind: StatefulSet
|
||
metadata:
|
||
name: vigimeteo-db
|
||
namespace: vigimeteo
|
||
labels:
|
||
app: vigimeteo-db
|
||
spec:
|
||
serviceName: vigimeteo-db
|
||
replicas: 1
|
||
selector:
|
||
matchLabels:
|
||
app: vigimeteo-db
|
||
template:
|
||
metadata:
|
||
labels:
|
||
app: vigimeteo-db
|
||
spec:
|
||
containers:
|
||
- name: postgres
|
||
image: postgres:17-alpine
|
||
ports:
|
||
- containerPort: 5432
|
||
name: postgres
|
||
env:
|
||
- name: POSTGRES_USER
|
||
value: "postgres"
|
||
- name: POSTGRES_PASSWORD
|
||
value: "admin"
|
||
- name: POSTGRES_DB
|
||
value: "postgres"
|
||
volumeMounts:
|
||
- name: vigimeteo-db-storage
|
||
mountPath: /var/lib/postgresql/data
|
||
- name: vigimeteo-db-init
|
||
mountPath: /docker-entrypoint-initdb.d
|
||
readinessProbe:
|
||
exec:
|
||
command: ["pg_isready", "-U", "postgres"]
|
||
initialDelaySeconds: 10
|
||
periodSeconds: 5
|
||
livenessProbe:
|
||
exec:
|
||
command: ["pg_isready", "-U", "postgres"]
|
||
initialDelaySeconds: 30
|
||
periodSeconds: 10
|
||
volumes:
|
||
- name: vigimeteo-db-storage
|
||
persistentVolumeClaim:
|
||
claimName: vigimeteo-db-pvc
|
||
- name: vigimeteo-db-init
|
||
configMap:
|
||
name: vigimeteo-db-init
|
||
|
||
---
|
||
|
||
# Headless Service – required by the StatefulSet
|
||
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: vigimeteo-db
|
||
namespace: vigimeteo
|
||
labels:
|
||
app: vigimeteo-db
|
||
spec:
|
||
clusterIP: None # headless – stable DNS name for StatefulSet pods
|
||
selector:
|
||
app: vigimeteo-db
|
||
ports:
|
||
- name: postgres
|
||
port: 5432
|
||
targetPort: 5432
|