Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes volume hostPath

I want to use kubernetes as my default development environment for that I set up the cluster locally with docker as explained in the official doc. I push my example to a github repository

My set up steps after having a kubernetes cluster running were:

* cd cluster_config/app && docker build --tag=k8s_php_dev . && cd ../..
* kubectl -s http://127.0.0.1:8080 create -f cluster_config/app/app.rc.yml
* kubectl -s http://127.0.0.1:8080 create -f cluster_config/app/app.services.yml

My issues comes since I want to map a local directory as a volume inside my app pod so I can share dynamically the files in there between my local host and the pod, so i can develop, change the files; and dynamically update on the service.

I use a a volume with a hostPath. The pod, replication controller and service are created successfully but the pod do not share the directory not even have the file on the supposed on the mountPath.

What I'm doing wrong?

Thanks

like image 711
bitgandtter Avatar asked Aug 13 '15 18:08

bitgandtter


1 Answers

The issue was on the volume definition, the hostPath.path property should hold the absolute address of the directory to mount.

Example:

hostPath:
  path: /home/bitgandtter/Documents/development/php/k8s_devel_env
like image 150
bitgandtter Avatar answered Oct 11 '22 21:10

bitgandtter