103 lines
1.9 KiB
YAML
103 lines
1.9 KiB
YAML
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: postgres
|
|
labels:
|
|
app: postgres
|
|
spec:
|
|
ports:
|
|
- port: 5432
|
|
selector:
|
|
app: postgres
|
|
tier: postgres
|
|
clusterIP: None
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: postgres-pv
|
|
labels:
|
|
type: local
|
|
spec:
|
|
capacity:
|
|
storage: 1Gi
|
|
volumeMode: Filesystem
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
persistentVolumeReclaimPolicy: Retain
|
|
storageClassName: manual
|
|
# TODO: change hostPath (short.slc.ar/YkdtaD)
|
|
hostPath:
|
|
path: /tmp/minikube/postgres
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: postgres-pv-claim
|
|
labels:
|
|
app: db
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
storageClassName: manual
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: postgres-secrets
|
|
type: Opaque
|
|
data:
|
|
username: dXNlcm5hbWU=
|
|
password: cGFzc3dvcmQxMjM0
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: db
|
|
labels:
|
|
app: db
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: db
|
|
tier: postgres
|
|
strategy:
|
|
type: Recreate
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: db
|
|
tier: postgres
|
|
spec:
|
|
containers:
|
|
- image: db:prod
|
|
name: postgres
|
|
env:
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: postgres-secrets
|
|
key: password
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
- name: POSTGRES_DB
|
|
value: db
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: postgres-secrets
|
|
key: username
|
|
ports:
|
|
- containerPort: 5432
|
|
name: postgres
|
|
volumeMounts:
|
|
- name: postgres-pv-storage
|
|
mountPath: /var/lib/postgresql/data
|
|
volumes:
|
|
- name: postgres-pv-storage
|
|
persistentVolumeClaim:
|
|
claimName: postgres-pv-claim |