☸️ Saving the file after performing job k8s

4/2/2021

After reading a lot of manuals, I still don't understand if it is possible to save a file to the host after performing a job or a cronjob.

My Job got PVC and PV like that:

volumes:
  - name:  name1
    persistentVolumeClaim:
      claimName: name2

and:

volumeMounts:
  - name: save-file
    mountPath: /mnt/dir

Let's say I'm running a script that saves the output to a file:

command: ["dosomething.py"]
args: [" --save-to-file output.txt"]

Is there some way to save it to the host or send it somewhere?

-- cryptoparty
kubernetes

1 Answer

4/2/2021

Mount the volume for container and give a mount path-

  volumeMounts:
    - name: "name1"
      mountPath: "/var/www/html"

The container can save file to it. Read more details here - https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume

-- subudear
Source: StackOverflow