Postgresql data is seemingly not persisted #1337
-
Hi, the issue I have currently is that /var/lib/postgresql is not being persisted across pod restarts but an added test file at /var/lib/postgresql/test is persisted between node switches and pod restarts and I dont understand why. postgresql.deployment.yaml apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
spec:
selector:
matchLabels:
app: postgresql
template:
metadata:
labels:
app: postgresql
spec:
containers:
- name: postgresql
image: postgres:16
ports:
- containerPort: 5432
env:
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
name: postgresql-config
key: POSTGRES_PASSWORD
volumeMounts:
- name: postgresql-data
mountPath: /var/lib/postgresql
volumes:
- name: postgresql-data
persistentVolumeClaim:
claimName: postgresql-pvc postgresql-pvc.yaml apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgresql-pvc
labels:
app: postgresql
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi postgresql-service.yaml apiVersion: v1
kind: Service
metadata:
name: postgresql
labels:
app: postgresql
spec:
clusterIP: None
selector:
app: postgresql
ports:
- port: 5432 Adding data to the database then restarting the pod causes all the changes to be lost, but adding a test file into the volume seems to persist. I can't seem to figure out why |
Beta Was this translation helpful? Give feedback.
Answered by
nixonjoshua98
May 4, 2024
Replies: 1 comment
-
I have to set a subPath on the mount, and mount directly onto /data volumeMounts:
- name: postgresql-data
mountPath: /var/lib/postgresql/data
subPath: postgresql |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nixonjoshua98
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have to set a subPath on the mount, and mount directly onto /data