postgresql-deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: postgresql
spec:
type: NodePort
selector:
app: postgresql
ports:
- protocol: TCP
port: 5432
targetPort: 5432
nodePort: 30432
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pg-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: pg-pv
nfs:
path: /data/pv/pg
server: k8s-master
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pg-pv-claim
spec:
storageClassName: pg-pv
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
spec:
replicas: 1
selector:
matchLabels:
app: postgresql
template:
metadata:
labels:
app: postgresql
spec:
containers:
- name: postgresql
image: postgres:13
env:
- name: POSTGRES_DB
value: jfrog
- name: POSTGRES_USER
value: jfrog
- name: POSTGRES_PASSWORD
value: jfrog
ports:
- containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: pg-pv-claim