Persistent volume claim - mount path

4/4/2020

I have a pv like below

apiVersion: v1
kind: PersistentVolume
metadata: 
  name: azurefile

spec:
  capacity:
    storage: 5Gi
  accessModes: 
    - ReadWriteMany
  storageClassName: azurefile
  azureFile:
    secretName: azure-secret
    shareName: cloudshare
    readOnly: false

and a pvc like below

apiVersion: v1
kind: PersistentVolumeClaim
metadata:  
  name: azurefile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile
  resources:
    requests:
      storage: 2Gi  

on deployments i have the following

      volumes:      
        - name: my-storage
          persistentVolumeClaim:
              claimName: azurefile
      volumeMounts:
          - name:  my-storage
            mountPath:  "/home/myapp/newapp/"

My understanding is that under the path /home/myapp/newapp/ in the containers ,the azure fileshare cloudshare's content will be accessible. So, whatever i have in cloudshare will be visible here. Does pvc or pv creates folders under the cloudshare? , the reason i ask is , I have a WORKDIR in my dockerimage which is actually in the same mountpath like below

WORKDIR /home/myapp/newapp/reta-app/ .

For some reason reta-app folder is getting created inside the cloudshare. Is this a normal behaviour or i am doing something wrong.

-- doc_noob
azure-files
docker
docker-compose
kubernetes

1 Answer

4/4/2020

Does pvc or pv create folders under the cloudshare?

No. A Kubernetes PersistentVolume is just some storage somewhere, and a PersistentVolumeClaim is a way of referencing a PV (that may not immediately exist). Kubernetes does absolutely no management of any of the content in a persistent volume; it will not create directories on startup, copy content from the image into a volume, or anything else.

-- David Maze
Source: StackOverflow