CronJobs in Kubernetes 1.21: Now in Full Bloom!
ayedo Redaktion 2 Minuten Lesezeit

CronJobs in Kubernetes 1.21: Now in Full Bloom!

Learn how the new GA version of CronJobs optimizes and simplifies your Kubernetes applications.
kubernetes kubernetes-news

In Kubernetes v1.21, the CronJob resource has reached General Availability (GA). This not only means that CronJobs are now stable and ready for production use, but also that we have significantly improved performance since Kubernetes v1.19 by implementing a new controller.

Already in Kubernetes v1.20, we introduced a revised v2 controller for CronJobs, initially available as an Alpha feature. In v1.21, we now use this newer controller by default, and the CronJob resource itself is now GA (GroupVersion: batch/v1).

What specifically changes for developers/DevOps teams?

For developers and DevOps teams, the introduction of GA CronJobs means they can rely on a more stable and powerful solution. The new controller architecture allows for better handling of CronJobs and improves the reliability of scheduled tasks in Kubernetes. The decision to promote the API beyond the Beta phase was made by the Kubernetes community to ensure that APIs do not remain in a “permanent Beta” state.

Practical examples or use cases

A concrete example of using CronJobs could be the regular backup of data in a database. Suppose you want to perform a backup of your database every day at midnight. With the new CronJob controller, you can achieve this simply and effectively:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: db-backup
spec:
  schedule: "0 0 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: backup
            image: my-backup-image
            args:
            - /bin/sh
            - -c
            - "pg_dump mydatabase > /backups/backup-$(date +\%F).sql"
          restartPolicy: OnFailure

With this configuration, a backup of your database is created every day at midnight. And thanks to the new controller implementation, you have to worry less about stability and performance, as these have now been significantly improved.

Switching to the new CronJob controller not only brings more reliability but also a significant increase in efficiency. At ayedo, we support you in making the most of Kubernetes and managing your container workloads efficiently.


Source: Kubernetes Blog

Ähnliche Artikel