k8s/manifests/02-deployments/deployment-postgres.yaml

75 lines
1.6 KiB
YAML
Raw Normal View History

2023-12-14 19:27:10 +10:00
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: pg
spec:
selector:
matchLabels:
app: postgres
replicas: 1
template:
metadata:
labels:
app: postgres
spec:
containers:
2023-12-14 19:42:44 +10:00
- 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
2023-12-14 19:44:16 +10:00
volumeMounts:
- mountPath: /var/lib/postgresql/data
2023-12-14 19:49:09 +10:00
name: postgredb
subPath: postgres
2023-12-14 19:42:44 +10:00
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
2023-12-14 19:36:07 +10:00
---
kind: PersistentVolume
apiVersion: v1
metadata:
2023-12-14 19:42:00 +10:00
namespace: pg
2023-12-14 19:36:07 +10:00
name: postgres-pv-volume
labels:
type: local
app: postgres
spec:
2023-12-14 19:39:04 +10:00
storageClassName: longhorn
2023-12-14 19:36:07 +10:00
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
2023-12-14 19:42:00 +10:00
namespace: pg
2023-12-14 19:36:07 +10:00
name: postgres-pv-claim
labels:
app: postgres
spec:
2023-12-14 19:39:04 +10:00
storageClassName: longhorn
2023-12-14 19:36:07 +10:00
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi