2021-08-27 04:57:25 +00:00
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: StatefulSet
|
|
|
|
metadata:
|
|
|
|
name: postgres
|
|
|
|
labels:
|
|
|
|
app.kubernetes.io/name: postgres
|
|
|
|
spec:
|
|
|
|
serviceName: postgres
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app.kubernetes.io/name: postgres
|
|
|
|
replicas: 1
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app.kubernetes.io/name: postgres
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- name: postgres
|
|
|
|
image: postgres
|
|
|
|
env:
|
|
|
|
- name: POSTGRES_DB
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: postgres-credentials-secret
|
|
|
|
key: database
|
|
|
|
- name: POSTGRES_USER
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: postgres-credentials-secret
|
|
|
|
key: username
|
|
|
|
- name: POSTGRES_PASSWORD
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: postgres-credentials-secret
|
|
|
|
key: password
|
|
|
|
- name: PGDATA
|
|
|
|
value: /data/pgdata
|
|
|
|
ports:
|
|
|
|
- name: postgres
|
|
|
|
containerPort: 5432
|
|
|
|
resources:
|
|
|
|
requests:
|
|
|
|
cpu: 500m
|
|
|
|
memory: 2Gi
|
|
|
|
limits:
|
|
|
|
cpu: 1000m
|
|
|
|
memory: 4Gi
|
|
|
|
volumeMounts:
|
|
|
|
- name: postgres-pvc
|
|
|
|
mountPath: /data
|
|
|
|
volumeClaimTemplates:
|
|
|
|
- metadata:
|
|
|
|
name: postgres-pvc
|
|
|
|
spec:
|
|
|
|
accessModes: ["ReadWriteOnce"]
|
|
|
|
resources:
|
|
|
|
requests:
|
2021-08-27 19:57:29 +00:00
|
|
|
storage: 3Gi
|
2021-08-27 04:57:25 +00:00
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: postgres
|
|
|
|
labels:
|
|
|
|
app.kubernetes.io/name: postgres
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
app.kubernetes.io/name: postgres
|
|
|
|
ports:
|
|
|
|
- name: postgres
|
|
|
|
port: 5432
|
|
|
|
targetPort: postgres
|