Copying the files and directories to the volume mount created in Rancher

12/6/2019

I am using Harness to deploy the image to Rancher. And this image needs the volume mount to run it. I have all the application specific data in this volume mount. While running the docker image manually in local system I am using the following command

docker run -dit -p 8082:80 -p 9002:443 -v /from_directory:/app/data/ 

And this works fine. But likewise i am using Harness to deploy the image to Rancher. So i have created the volume mount called app/data/ volume in the rancher. And from harness i am specifying that use this volume mount that i have created to fetch the data like this

volumes:
      - name: /app/data
        persistentVolumeClaim:
          claimName: volume-claim

So that while deploying from harness it will come to know there is volume mount present in Rancher/Kubernetis but i need to copy the directories and files which are stored in another server to the volume mount that i created in the Rancher.And this copy should happen only after the POD pulls the image.

I know that we can use

kubectl cp <file-spec-src> <file-spec-dest> -c <specific-container>

Command to copy file from server to the volume mount i have created. But i need some events or place where I can write this command and every time I tried to deploy using Harness it should execute above command and copy the files and directories without me entering the command. Is there anything like that which i can automate this process?

-- Manjunath M
devops
docker
docker-volume
kubernetes
rancher

0 Answers