-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg-master-statefulset.yaml
48 lines (45 loc) · 1.12 KB
/
pg-master-statefulset.yaml
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
# pg-master-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: pg-master
spec:
serviceName: pg-master
replicas: 1
selector:
matchLabels:
app: postgres
role: master
template:
metadata:
labels:
app: postgres
role: master
spec:
securityContext:
runAsUser: 999 # PostgreSQL user UID
runAsGroup: 999 # PostgreSQL group GID
fsGroup: 999
containers:
- name: postgres
image: postgres:15
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "password"
- name: PGDATA
value: "/var/lib/postgresql/data"
volumeMounts:
- name: pg-data # Mount the data directory
mountPath: /var/lib/postgresql/data
- name: pg-config-path
mountPath: /etc/postgresql/custom
volumes:
- name: pg-data
persistentVolumeClaim:
claimName: pg-master-pvc # Reference pre-created data PVC
- name: pg-config-path
configMap:
name: pg-config
defaultMode: 0755