1
0
Fork 0
home-stack-kustomize/kustomize/bases/postgres/postgres-statefulset.yaml

75 lines
1.7 KiB
YAML
Raw Normal View History

2021-08-27 04:57:25 +00:00
# PostgreSQL StatefulSet
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
# Volume Claim
volumeClaimTemplates:
- metadata:
name: postgres-pvc
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
---
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