-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk8s-statefulset.yaml
More file actions
118 lines (111 loc) · 2.68 KB
/
k8s-statefulset.yaml
File metadata and controls
118 lines (111 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
# PersistentVolumeClaim for delta storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: diffkeeper-deltas
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi # Small storage for deltas only
---
# StatefulSet with DiffKeeper + Postgres
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres-with-diffkeeper
spec:
serviceName: postgres
replicas: 1
selector:
matchLabels:
app: postgres-diffkeeper
template:
metadata:
labels:
app: postgres-diffkeeper
spec:
containers:
- name: postgres-diffkeeper
image: diffkeeper-postgres:latest
imagePullPolicy: Never # Use local image (for minikube/kind)
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_PASSWORD
value: "password"
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_DB
value: "testdb"
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
- name: delta-storage
mountPath: /deltas
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
volumes:
- name: delta-storage
persistentVolumeClaim:
claimName: diffkeeper-deltas
- name: postgres-data
emptyDir: {} # Ephemeral - DiffKeeper will restore from deltas
---
# Service for Postgres
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
ports:
- port: 5432
name: postgres
clusterIP: None
selector:
app: postgres-diffkeeper
---
# Test Job - Creates sample data
apiVersion: batch/v1
kind: Job
metadata:
name: diffkeeper-test-data
spec:
template:
spec:
containers:
- name: psql-client
image: postgres:16-alpine
command:
- /bin/sh
- -c
- |
# Wait for Postgres to be ready
until pg_isready -h postgres -U postgres; do
echo "Waiting for postgres..."
sleep 2
done
# Create test table and data
PGPASSWORD=password psql -h postgres -U postgres -d testdb <<EOF
CREATE TABLE IF NOT EXISTS test_data (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
created_at TIMESTAMP DEFAULT NOW()
);
INSERT INTO test_data (name) VALUES
('Test Entry 1'),
('Test Entry 2'),
('Test Entry 3');
SELECT COUNT(*) as total FROM test_data;
EOF
echo "Test data created successfully!"
restartPolicy: Never
backoffLimit: 4