Use host mount approach in the kubernetes.
Example YAML
Example YAML to mount host point to POD
root@ubuntu-232:~/deepak# cat hostmount.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: ubuntu:latest
command: [ "/bin/bash", "-c", "--" ]
args: [ "apt-get -y install vim;while true; do sleep 30; done;" ]
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
root@ubuntu-232:~/deepak#
Example log
Example log
From host machine
root@ubuntu-231:~/deepak# cd /data/
root@ubuntu-231:/data# touch abcd
root@ubuntu-231:/data#
root@ubuntu-231:/data# ls
abcd efgh
Within container
root@ubuntu-232:~/deepak# kubectl exec -it test-pd bash
root@test-pd:/# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /bin/bash -c -- apt-get -y install vim;while true; do sleep 30; done;
22 ? S 0:00 sleep 30
23 ? Ss 0:00 bash
32 ? R+ 0:00 ps ax
root@test-pd:/#
root@test-pd:/# cd /test-pd/
root@test-pd:/test-pd# ls
root@test-pd:/test-pd# ls
abcd
root@test-pd:/test-pd#
root@test-pd:/test-pd# touch efgh
root@test-pd:/test-pd# pwd
/test-pd
root@test-pd:/test-pd# ls
abcd efgh
Useful link: https://stackoverflow.com/questions/46951466/how-to-mount-external-directory-in-kubernetes-service