简体   繁体   English

Kubernetes - cron 作业未清理 pod

[英]Kubernetes - cron jobs not cleaning up pods

Having recently updated to version 1.22.1, we are now experiencing an issue where the existing cron jobs are no longer deleting pods once they are complete.最近更新到版本 1.22.1,我们现在遇到了一个问题,即现有的 cron 作业在完成后不再删除 pod。 i have tried adding the following:我尝试添加以下内容:

successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 5 to the yaml, but has had no effect. successJobsHistoryLimit: 3 failedJobsHistoryLimit: 5 到 yaml,但没有任何效果。

I have also used a simple cron job example:我还使用了一个简单的 cron 作业示例:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

after 5 minutes, all the pods are still there 5分钟后,所有的豆荚都还在

kubectl get pods

hello-27304804--1-q545h   0/1     Completed   0          5m21s
hello-27304805--1-b6ksd   0/1     Completed   0          4m21s
hello-27304806--1-dsvb7   0/1     Completed   0          3m21s
hello-27304807--1-bqnjg   0/1     Completed   0          2m21s
hello-27304808--1-dsv6p   0/1     Completed   0          81s
hello-27304809--1-99cx4   0/1     Completed   0          21s

kubectl get jobs

NAME             COMPLETIONS   DURATION   AGE
hello-27304828   1/1           1s         2m59s
hello-27304829   1/1           2s         119s
hello-27304830   1/1           2s         59s

A workaround is setting a pod limit on a namespace via resourcequotas and sticking the cron jobs in there.一种解决方法是通过 resourcequotas 在命名空间上设置 pod 限制,并将 cron 作业固定在那里。 Hope this helps: src : Unable to run .netcore app as kubernetes cronjob希望这会有所帮助: src : Unable to run .netcore app as kubernetes cronjob

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM