Retrieve output from completed pod 'kubernetes'

6/14/2021

How can i retrieve any directory/file from the completed pod of a particular job in kubernetes? I am trying to store the output file locally from the container.

-- 0001000
kubernetes
kubernetes-jobs

2 Answers

6/15/2021

Kubernetes pods don't maintain state by default. You will need to use persistent volumes for data persistence (PVC/PV).

In order to retrieve files/directories from a completed job, you will have to mount the same persistent volume to another pod after your job is completed in order to retrieve the "output file"

-- Rakesh Gupta
Source: StackOverflow

6/15/2021

Thanks for the suggestion!! I finally manage to do it by using init-container along with main container... one to run the real functioning i want the job for and another one to let the container sleep and then mounted an empty directory (PVC too can be used ofcourse) and shared with both main container and init-container.

-- 0001000
Source: StackOverflow