Search code examples
kubernetesdeploymentkubernetes-helmkubernetes-pvc

Kubernetes. Is it possible to mount volume to path containing pod id?


I want to define pvc and create volume in order to get some internal files from container outside (I am using helm charts definitions). I want to know is there any way to use POD IP in mountPath that I am defining in deployment.yaml.

At the end I want to get folder structure in my node /dockerdata-nfs//path

volumeMounts:
     - name: volumeName
       mountPath: /abc/path

volumes:
    - name: volumeName
      hostPath:
        path: /dockerdata-nfs/podID/

Solution

  • POD on recreation will get a new UID so why will you try to hard code this value !!

    Pods are considered to be relatively ephemeral (rather than durable) entities. As discussed in pod lifecycle, Pods are created, assigned a unique ID (UID), and scheduled to nodes where they remain until termination (according to restart policy) or deletion. If a Node dies, the Pods scheduled to that node are scheduled for deletion, after a timeout period. A given Pod (as defined by a UID) is not “rescheduled” to a new node; instead, it can be replaced by an identical Pod, with even the same name if desired, but with a new UID (see replication controller for more details).