I am using Kubernetes static PV to mount my Postgresql data. But I am unable to do this
Here is my YAML file where I create PV , PVC and my Postgres pod
my data directory of Postgres located at “/var/lib/pgsql/9.3/data”
But initially, my data directory /var/lib/pgsql/9.3/data is nonempty. I already append some sample data here. I want that Kubernetes will create the volume in the same location and mount it to /mnt/data
I also provide permissions and ownership but my problem still not fixed. The same thing works fine if I use docker volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
namespace: manhattan
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
namespace: manhattan
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 80Mi
---
apiVersion: v1
kind: Pod
metadata:
name: dbr-postgres
namespace: manhattan
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: postgresql:2.0.1
tty: true
volumeMounts:
- mountPath: "/var/lib/pgsql/9.3/data"
name: task-pv-storage
subPath: data
readOnly: false
nodeSelector:
kubernetes.io/hostname: k8s-master
Can anyone tell me what I am doing wrong?
Cluster information:
Kubernetes version: v1.16.2
Cloud being used: locally
Installation method: kubeadem
Host OS: Linux (Centos 7)
CNI and version:
CRI and version:
You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.