2

I have a Job pod with two containers, worker and sidecar. The sidecar container exposes a REST API via a service.

While the worker container is active, the sidecar container REST API functions as expected.

However, after the worker completes/exits, the sidecar is no longer reachable. I was able to determine that the network endpoints become disabled once the worker container exits.

Is it possible to configure the pod such that the network endpoints remain active as long as there are still containers running in the pod?

arosca
  • 469
  • 7
  • 15
  • Why do you need sidecar for Job resource? Maybe it will be better to use custom Job `operator` which can track and handle job execution? – SKorolchuk Apr 04 '19 at 17:00
  • As you suspected, the sidecar does some cleanup. I'm not familiar with operators. Is this a new feature? Could you please point me to docs? I found this but I'm not sure if that's what you are referring to: https://coreos.com/operators/ – arosca Apr 04 '19 at 19:14
  • 1
    Ok, clean up seems to be necessary for the task. If you want to track current situation about your issue, check links: [Issue about Job sidecar support](https://github.com/kubernetes/kubernetes/issues/25908) [SIG about sidecar support enhancement](https://github.com/kubernetes/enhancements/blob/master/keps/sig-apps/sidecarcontainers.md) – SKorolchuk Apr 04 '19 at 21:46
  • 1
    What's about Operator SDK - it's a way to implement pod management for custom resources with specific functionality and lifecycle. For example, [airflow-operator](https://github.com/GoogleCloudPlatform/airflow-operator) implements integration of Apache Airflow with k8s. Other example is [spark-operator](https://github.com/GoogleCloudPlatform/spark-on-k8s-operator). Sometimes it's simpler to create custom scheduler or use [downward API](https://stackoverflow.com/questions/36208211/sidecar-containers-in-kubernetes-jobs). – SKorolchuk Apr 04 '19 at 21:46

1 Answers1

1

This is expected behaviour as of https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#job-termination-and-cleanup.

Rick Rackow
  • 1,490
  • 8
  • 19
  • Right, that's what I was able to gather from the docs as well. I was asking whether it's possible to configure the pod for different behavior. – arosca Apr 05 '19 at 16:02
  • Hey, super sorry I missed your answer. As far as I know, it is not. – Rick Rackow Jul 01 '19 at 15:33