3

I am trying to create a Kubernetes job, that would run from some machine. I would like that job could somehow copy files from this machine into container running within job itself and do something with them. First of all, is it a good approach? Secondly, how could I do that? My k8s job is supposed to run some pre-built image from registry. I know I could build such image by myself and include desired files into that however I wonder if I can skip that step? I've read also about configMaps, however they are flat and my templates folder can also have folder inside.

Let's have an example: Machine X has directory /templates. I run kubectl apply -f my-job.yaml and I would like that this container inside of this job would have the same files as these located in /templates.

Would be grateful for any tips how to achieve that.

Tomek
  • 101
  • 1
  • 9
  • If you want to have the same files in your job pod, you should mount the same volume in the pod and copy ir or handle the files in the mounted volume. The '/templates' should be a volume. This directory is a node folder? – Mr.KoopaKiller Nov 09 '20 at 10:41
  • Directory is completely outside of cluster itself. I would like that these files from directory were mounted somehow when deployment is done. – Tomek Nov 09 '20 at 11:00
  • You should use [persistent volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) to do it. For example, you can use [NFS](https://kubernetes.io/docs/concepts/storage/volumes/#nfs) to share your volume and them mount in a pod. Is it works for you? – Mr.KoopaKiller Nov 10 '20 at 08:55

1 Answers1

0

you can create a configmap ,then mount it on pod

focus zheng
  • 345
  • 1
  • 4
  • 12