Welcome to the Linux Foundation Forum!

LFD259: Lab 4.3

I have double and triple checked my cronjob.yaml file and yet whenever I run it I get this:

Error from server (BadRequest): error when creating "cronjob.yaml": Job in version "v1" cannot be handled as a Job: strict decoding error: unknown field "spec.jobTemplate", unknown field "spec.schedule"

I have tried left justifying everything and then using the spacebar to space just like in the image shown in the instructions so the letters of the lower line line up correctly with the second character in the upper line. It just does not seem to want to accept these two fields.

apiVersion: batch/v1 kind: Job metadata: name: sleepy spec: schedule: "*/2 * * * *" jobTemplate: spec: template: spec: containers: - name: resting image: busybox command: ["/bin/sleep"] args: ["3"] restartPolicy: Never

Answers

  • The code didn't retain formatting so here is a screen shot:

  • chrispokorni
    chrispokorni Posts: 2,372

    Hi @rasputin312,

    In the SOLUTIONS tarball you can find a cronjob.yaml file ready to use, that seems to be correct.

    However, from your screenshot, your definition file seems to be correct with the exception of line 2. It still says kind: Job, when in fact you are defining a CronJob object. This required change can be observed in step 2 of lab 4.3 of the lab guide.

    Regards,
    -Chris

  • Thanks that was the issue. Missed that.

Categories

Upcoming Training