75 lines
1.6 KiB
YAML
75 lines
1.6 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: postgres
|
|
namespace: pg
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: postgres
|
|
replicas: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: postgres
|
|
spec:
|
|
containers:
|
|
- name: postgres
|
|
image: postgres:latest
|
|
imagePullPolicy: "IfNotPresent"
|
|
env:
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: postgres-secret
|
|
key: postgres-root-username
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: postgres-secret
|
|
key: postgres-root-password
|
|
- name: POSTGRES_DB
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: postgres-configmap
|
|
key: postgres-dbname
|
|
volumeMounts:
|
|
- mountPath: /var/lib/postgresql/data
|
|
name: postgredb
|
|
subPath: postgres
|
|
volumes:
|
|
- name: postgredb
|
|
persistentVolumeClaim:
|
|
claimName: postgres-pv-claim
|
|
---
|
|
kind: PersistentVolume
|
|
apiVersion: v1
|
|
metadata:
|
|
namespace: pg
|
|
name: postgres-pv-volume
|
|
labels:
|
|
type: local
|
|
app: postgres
|
|
spec:
|
|
storageClassName: longhorn
|
|
capacity:
|
|
storage: 5Gi
|
|
accessModes:
|
|
- ReadWriteMany
|
|
hostPath:
|
|
path: "/mnt/data"
|
|
---
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
namespace: pg
|
|
name: postgres-pv-claim
|
|
labels:
|
|
app: postgres
|
|
spec:
|
|
storageClassName: longhorn
|
|
accessModes:
|
|
- ReadWriteMany
|
|
resources:
|
|
requests:
|
|
storage: 5Gi |