Replies: 4 comments
-
What mechanism for submitting jobs do you have in mind? |
Beta Was this translation helpful? Give feedback.
-
Hello. Thanks for asking. I have no idea how this could be implemented the best way. Maybe, I would take a look at Kubernetes's built-in affinity & anti-affinity tools for this, or at Kubernetes's system resource allocation (if it can create pseudo-resources, not only CPU/RAM/GPU). Or maybe even looked at the task itself from a different angle and tried to redesign the whole solution. It looks like the XY Problem here: you are looking for a technical solution Y as presumably the only solution for the original unspoken problem X, while there can be other better solutions. Kopf can probably solve this task too, as long as you manipulate import kopf
@kopf.index('jobs', labels={'marker': 'xyz'}, field='spec.suspend', value=True)
def xyz_jobs(namespace, name, **_):
return {(namespace, name): None}
def has_just_finished(old, new, **_):
return False # TODO: somehow, detect if it was done
@kopf.on.update('jobs', when=has_just_finished)
def job_finished(xyz_jobs, **_):
all_pending_jobs = set(xyz_jobs)
next_job_ns, next_job_name = random.choice(all_pending_jobs)
patch_job(next_job_ns, next_job_name, {'spec': {'suspend': False}}) This, however, looks like an overcomplication. And definitely, it is not finished — just the overall idea. |
Beta Was this translation helpful? Give feedback.
-
Kyverno can implement this check fairly easily using poiicies |
Beta Was this translation helpful? Give feedback.
-
@mezhaka did you find a solution for this? I have the exact same use-case, so I'm wondering if/how you were able to achieve limiting these jobs? |
Beta Was this translation helpful? Give feedback.
-
Here's a scenario: I keep on submitting jobs with some
label
. Say I have submittedN+K
jobs, but only up toN
jobs would be able to create pods and transition to Running state, while the restK
will sit till some of the firstN
jobs finish. In other words only up toN
jobs that match some label filter may run simultaneously.Beta Was this translation helpful? Give feedback.
All reactions