Skip to main content

Updating CronJob API version for Cloud Platform - deprecated Kubernetes v1.21

The batch/v1beta1 API version of CronJob is deprecated as of Kubernetes release v1.21, and will no longer be served as of v1.25.

Cloud Platform users are encouraged to ensure any CronJob manifests are migrated to use the batch/v1 API version, which is supported on our current cluster version (v1.24 as of writing).

Further details can be found within the Kubernetes deprecation guide

Steps required

To view which apiVersion you are using, run the following kubectl command:

kubectl --namespace <namespace> get cronjob <cronjob-name> -o yaml

apiVersion: batch/v1beta1
kind: CronJob
...

You are only required to update apiVersion as the following complete example shows:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "1 2-14 * * 0-1,5-6"
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 100
      template:
        spec:
          containers:
          - name: hello
            image: bitnami/nginx
            args:
            - /bin/sh
            - -c
            - date; echo "Hello, World!"
          restartPolicy: OnFailure

For additional information on creating CronJobs see here

This page was last reviewed on 10 July 2023. It needs to be reviewed again on 10 October 2023 by the page owner #cloud-platform .
This page was set to be reviewed before 10 October 2023 by the page owner #cloud-platform. This might mean the content is out of date.