75 lines
1.7 KiB
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: 500m
|
|
memory: 1Gi
|
|
limits:
|
|
cpu: 500m
|
|
memory: 1Gi
|
|
volumeMounts:
|
|
- name: postgres-pvc
|
|
mountPath: /data
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: postgres-pvc
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 3Gi
|
|
---
|
|
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
|