Kubernetes CronJob 仅运行相同的作业,即使其他作业正在等待每个节点条件的有限数量 pods

Kubernetes CronJob only runs the same job even though other jobs are waiting in limited number of pods per node condition

我想知道当有多个等待作业时,kubernetes CronJob 如何选择作业到 运行。 不是先进先出,而是后进先出?

这是我实验的设置。

我安排了 9 个 CronJobs (cronjob1..cronjob9),名称不同。 每个作业如下:

这是结果。

更新

namespace.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: cron-job-ns

resource_quota.yaml

apiVersion: v1
kind: ResourceQuota
metadata:
  name: limit-number-of-pods
  namespace: cron-job-ns
spec:
  hard:
    count/pods: "3"

我已经发布了社区维基答案来总结主题。

I'd like to know how kubernetes cron job chooses the job to run when there are multiple waiting jobs. It is not FIFO, but LIFO?

用户rkosegi评论中提到的好:

it's nether LIFO nor FIFO. It's much more complicated.

用户weibeld添加了说明:

As mentioned by @rkosegi, this has probably more to do with the Kubernetes scheduler than with CronJobs and Jobs. All Jobs create a Pod when they are started by the CronJob according to its schedule. The scheduler then decides which of the pending Pods gets scheduled to the node and thus can run.

如果您想准确了解其工作原理,请参阅以下文档:

Kubernetes Scheduler Fine Parallel Processing Using a Work Queue Jobs

正如你们所回答的,它在 Kubernetes 调度程序的范围内。

特别是同类型等待的优先级pods,如本次实验,与Kubernetes调度器中的Queue有关

The Queue implementation 既不是 FIFO 也不是 LIFO。

等待的Pod好像根据超时时间在activeQ、podBackoffQ、unschedulableQ三个队列之间来回切换。

超时时间与CronJob新调度的Pod的关系决定了下一个要执行的Pod