I am trying to run postgres:13-alpine in Kubernetes cluster.
I have next Kubernetes manifest
PV
kind: PersistentVolume
apiVersion: v1
metadata:
name: open-imis-pv-volume
labels:
type: local
app: postgres
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: /mnt/data
PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: open-imis-pv-claim
namespace: open-imis
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: open-imis-db
namespace: open-imis
labels:
app: open-imis-db
spec:
selector:
matchLabels:
app: open-imis-db
strategy:
type: Recreate
template:
metadata:
labels:
app: open-imis-db
spec:
containers:
- image: postgres:13-alpine
name: open-imis-db
env:
- name: open-imis-secret
valueFrom:
secretKeyRef:
name: open-imis-secret
key: password
ports:
- containerPort: 5432
name: postgres
volumeMounts:
- name: postgres
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres
persistentVolumeClaim:
claimName: open-imis-pv-claim
More details in the Pull Request
Could you help me to figure out the reason why pod CrashLoopBackOff
with next error:
PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-04-04 16:38:05.912 UTC [1] FATAL: database files are incompatible with server
2023-04-04 16:38:05.912 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.10.
I don't set explicitly PostgreSQL version 12 anywhere. Where does it come from?
The issue was with a mount path for 13 version I have to use
mountPath: /var/lib/pgsql/data
not
mountPath: /var/lib/postgresql/data