kubernetes volume hostPath

10,515

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
Share:
10,515
bitgandtter
Author by

bitgandtter

Love Software Development, enforce good Software Architecture and practice DevOps with CI/CD focus

Updated on June 23, 2022

Comments

  • bitgandtter
    bitgandtter almost 2 years

    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

  • CJ Cullen
    CJ Cullen over 8 years
    Glad you found your answer!