72 lines
1.7 KiB
YAML
72 lines
1.7 KiB
YAML
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: replica
|
|
namespace: cluster1
|
|
spec:
|
|
serviceName: replica
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: replica
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: replica
|
|
spec:
|
|
containers:
|
|
- name: postgres
|
|
image: postgres:15-alpine
|
|
ports:
|
|
- containerPort: 5432
|
|
env:
|
|
- name: POSTGRES_DB
|
|
value: replica_db
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: cluster1-postgres-secret
|
|
key: POSTGRES_USER
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: cluster1-postgres-secret
|
|
key: POSTGRES_PASSWORD
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
chmod +x /replication-scripts/entrypoint-replica.sh
|
|
exec /replication-scripts/entrypoint-replica.sh
|
|
volumeMounts:
|
|
- name: replica-data
|
|
mountPath: /var/lib/postgresql/data
|
|
- name: replication-scripts
|
|
mountPath: /replication-scripts
|
|
volumes:
|
|
- name: replica-data
|
|
persistentVolumeClaim:
|
|
claimName: replica-data
|
|
- name: replication-scripts
|
|
configMap:
|
|
name: cluster1-replication-scripts
|
|
defaultMode: 0755
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: replica
|
|
namespace: cluster1
|
|
spec:
|
|
type: ClusterIP
|
|
selector:
|
|
app: replica
|
|
ports:
|
|
- name: postgres
|
|
port: 5432
|
|
targetPort: 5432
|
|
|
|
|