openshiftkubernetes-cronjobtekton-pipelines

CronJob: unknown field "jobTemplate"


apiVersion: tekton.dev/v1beta1
kind: CronJob
metadata:
  name: nightly-test
  namespace: team-dev
spec:
  schedule: "0 1 * * *"
  jobTemplate:
    spec:
      backoffLimit: 6
      ttlSecondsAfterFinished: 30
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: "false"
        spec:
          containers:
            - name: nightly-test
              image: server.company.nl/node:16.15.0
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
                - -c
                - |
                  npm install playwright
                  mkdir tests
                  echo "" > tests/chat.spec.js
                  npx playwright test --retries=3
                  curl -i -k -X POST -H 'Content-Type: application/json' -d '{"text": "Nightly Cron Job ran! TODO: add result","username":"Cron Job notifier" }' https://server.company.nl/hooks/key
          restartPolicy: Never

I suspect that's due to apiVersion not being batch/v1beta1 but if i try that, OpenShift Console says

the API version in the data (batch/v1beta1) does not match the expected API version (tekton.dev/v1beta1)

The rest is based on an existing CronJob here so the CronJob plugin should be active, but then why does it say

admission webhook "webhook.pipeline.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "jobTemplate"

if kind and schedule are okay?


Solution

  • In the Openshift Container Platform menu, choose Workloads → Cronjobs, not Pipelines → Pipelines.