I am trying to mount a specific file from a folder containing multiple files & folders of a kubernetes pod into the host machine's path as a backup.
I am using PersistentVolumeClaim as a volume and am able to mount the complete folder instead of that specific file. And this folder is accessible via the host machine's path.
Following are my deployment, PVC and PV files.
Deployment file:
containers:
- name: katana-db
image: postgres:10.4
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: war-config
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: katana-db
volumes:
- name: katana-db
persistentVolumeClaim:
claimName: katana-db-volume-claim
Persistent Volume Claim:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: katana-db-volume-claim
namespace: {{ $.Values.namespace }}
creationTimestamp: null
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
volumeName: "katana-db-volume"
---
Persistent Volume:
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: katana-db-volume
namespace: {{ $.Values.namespace }}
spec:
storageClassName: manual
capacity:
storage: 2Gi
persistentVolumeReclaimPolicy: Retain
accessModes:
- ReadWriteMany
nfs:
path: /mnt/k8sMount/data/local-persist/data/warrior/katana-db
server: 167.xx.xx.xx
---
I want to mount the file "/var/lib/postgresql/data/config.ini" instead of the complete folder "/var/lib/postgresql/data" that I mentioned in the deployment file so that I can have a backup of this file in my host machine.
I found "hostpath" volume but it seems to be unfit for production as suggested by kubernetes forums.
Please let me know the volume that I can use to mount a specific file from a folder within a Pod so that I can access it via the host machine.