0

So, I created sample job from the docs:

apiVersion: batch/v1beta1
kind: Job
metadata:
  name: pi-with-ttl
  namespace: ish
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: pi
        image: perl:5.34.0
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never

And I don't see ttlSecondsAfterFinished there

kubectl -n ish get job.batch/pi-with-ttl -o yaml

apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"name":"pi-with-ttl","namespace":"ish"},"spec":{"template":{"spec":{"containers":[{"command":["perl","-Mbignum=bpi","-wle","print bpi(2000)"],"image":"perl:5.34.0","name":"pi"}],"restartPolicy":"Never"}},"ttlSecondsAfterFinished":100}}
  creationTimestamp: "2023-04-26T19:35:20Z"
  labels:
    controller-uid: 4bf27c42-ac18-4fb3-a5f2-6cccf6b495a6
    job-name: pi-with-ttl
  name: pi-with-ttl
  namespace: ish
  resourceVersion: "231774076"
  uid: 4bf27c42-ac18-4fb3-a5f2-6cccf6b495a6
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  selector:
    matchLabels:
      controller-uid: 4bf27c42-ac18-4fb3-a5f2-6cccf6b495a6
  template:
    metadata:
      creationTimestamp: null
      labels:
        controller-uid: 4bf27c42-ac18-4fb3-a5f2-6cccf6b495a6
        job-name: pi-with-ttl
    spec:
      containers:
      - command:
        - perl
        - -Mbignum=bpi
        - -wle
        - print bpi(2000)
        image: perl:5.34.0
        imagePullPolicy: IfNotPresent
        name: pi
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  completionTime: "2023-04-26T19:36:10Z"
  conditions:
  - lastProbeTime: "2023-04-26T19:36:10Z"
    lastTransitionTime: "2023-04-26T19:36:10Z"
    status: "True"
    type: Complete
  startTime: "2023-04-26T19:35:20Z"
  succeeded: 1

Job lives forever

NAME                    COMPLETIONS   DURATION   AGE
job.batch/pi-with-ttl   1/1           50s        19h

At the same time I have sample cronjob with ttlSecondsAfterFinished and it's working as expected.

kubectl -n ish cronjob platform-core-base-auto-check-in -o yaml

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  annotations:
---
spec:
  ttlSecondsAfterFinished: 86400

Am I missing something?

ISH91
  • 41
  • 4
  • what version is your cluster on? `batch/v1beta1` should be deprecated since a while and shortly after `ttlSecondsAfterFinished` actually went stable. Asking as when I adjust the version correctly to `batch/v1` I also can't reproduce your issue and the `ttlSecondsAfterFinished` shows up as expected – Rick Rackow Apr 27 '23 at 18:17
  • @RickRackow 1.20 – ISH91 Apr 28 '23 at 16:17
  • I'd recommend upgrading. This wasn't stable back then and with everything that's beta "there may be dragons" – Rick Rackow Apr 29 '23 at 17:12
  • 1
    @RickRackow yep, upgrade resolve it ;) – ISH91 Jun 10 '23 at 09:37
  • made this an answer so it's a little more obvious for anyone else – Rick Rackow Aug 07 '23 at 10:32

1 Answers1

0

I'd recommend upgrading. This wasn't stable back then and with everything that's beta "there may be dragons"

You can read more about the expectations towards beta versions here

Rick Rackow
  • 1,490
  • 8
  • 19