1

I have a Pod that has two regular (i.e. not Init) Containers. One of them is meant to be used as a "job", i.e. it should run a script and then exit while the other container should keep running. The problem is that as soon as the "job" container is finished, the Pod will be marked as NotReady due to all containers not being Ready. Can I somehow make this "job" container for Pod-readiness optional? Is there anything better than having sleep 1000000000 in the "job" container's command?

Note that:

  • I cannot make this "job" container an InitContainer because it cannot run before the other container
  • I could use a k8s Job for that although it'd be way easier for my specific use-case to run this "job" container in the same Pod as I'd like it to share network and some volumes with the other container. Jobs unfortunately cannot "bind" to an existing Pod.
Mike
  • 842
  • 1
  • 9
  • 31
  • Does this answer your question? [How can I ignore failure of a container in multi-container pod?](https://stackoverflow.com/questions/57593518/how-can-i-ignore-failure-of-a-container-in-multi-container-pod) – larsks Aug 02 '22 at 01:03
  • I think the best solution is simply to run `sleep inf` in the "job" container when it is done. Alternately, just make it a `Job`: while it can't bind to the same pod, it *can* share volumes with the pod (e.g., via persistent volume claims), and it can access pod network services via `Service` objects. – larsks Aug 02 '22 at 01:05
  • whats the job container actually do? may be there are other way around to get the desired with pod life cycle event – Adiii Aug 02 '22 at 02:04
  • «One of them is meant to be used as a "job", i.e. it should run a script and then exit while the other container should keep running.» That sounds to me like the definition of initContainer. Can you explain why it can't be an initContainer? – whites11 Aug 02 '22 at 06:43

0 Answers0