how to copy data generated by kuberenetes pods to PV in manifest

2/22/2022

I have following Pod Yml, I am successfully able to get data generated by container in docker in attached volume, I created images form same docker file and pull images in Kuberentes, I have also attached PV to Pod, when i login to pod during running condition I can see Pod is able to generated data, I tried to mount to PV to folder I got and error . If I mount PV to another location, generated data is not able to save in PV, after Pod kill , all generated data are gone.

pod.yml

apiVersion: v1
kind: Pod
metadata:
  name: pullandmerge
spec:
  containers:
  - name: pullandmerge
    image: azurecr.io/pullandmerge:v1
    
             
    volumeMounts:
            - name: my-azurefile-volume
              mountPath: /data-temp # if i change this to /data, no error but data is not saved to PV
              # what can I do to move data geenrated by pod to PV
  volumes:
        - name: my-azurefile-volume
          persistentVolumeClaim:
            claimName: my-azurefile-pvc

  restartPolicy: Never

Dockerfile

From ububtuu:latest
RUN mkdir -p /data-temp
WORKDIR /data-temp
COPY ..
ENTRYPOINT ["pyhton3", "/data-temp/pull_and_merge_data.py", "bash"]

error I got [Error2} no such file or directory cannot opne file /data-temp/pull_and_merge_data.py'

-- shanman
dockerfile
kubernetes

0 Answers