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

75 lines
1.7 KiB
YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
labels:
app.kubernetes.io/component: postgres
spec:
serviceName: postgres
selector:
matchLabels:
app.kubernetes.io/component: postgres
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/component: postgres
spec:
containers:
- name: postgres
image: postgres
env:
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: postgres-credentials
key: database
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-credentials
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: password
- name: PGDATA
value: /data/pgdata
ports:
- name: postgres
containerPort: 5432
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 2000m
memory: 1Gi
volumeMounts:
- name: postgres-pvc
mountPath: /data
volumeClaimTemplates:
- metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
app.kubernetes.io/component: postgres
spec:
selector:
app.kubernetes.io/component: postgres
ports:
- name: postgres
port: 5432
targetPort: postgres