As far as I know, when most people want to know if a Kubernetes
(or Spark
even) Job
is done, they initiate some sort of loop somewhere to periodically check if the Job
is finished with the respective API
.
Right now, I'm doing that with Kubernetes
in the background with the disown
(&
) operator (bash
inside Python
below):
import subprocess
cmd = f'''
kubectl wait \\
--for=condition=complete \\
--timeout=-1s \\
job/job_name \\
> logs/kube_wait_log.txt \\
&
'''
kube_listen = subprocess.run(
cmd,
shell = True,
stdout = subprocess.PIPE
)
So... I actually have two (correlated) questions:
- Is there a better way of doing this in the background with
shell
other than with the&
operator? - The option that I think would be best is actually to use
cURL
from inside theJob
to update myLocal Server API
that interacts withKubernetes
.- However, I don't know how I can perform a
cURL
from aJob
. Is it possible? - I imagine you would have to expose ports somewhere but where? And is it really supported? Could you create a
Kubernetes
Service
to manage the ports and connections?
- However, I don't know how I can perform a