digitalocean / DOKS

Managed Kubernetes designed for simple and cost effective container orchestration.
https://www.digitalocean.com/products/kubernetes/
Apache License 2.0
80 stars 4 forks source link

Cronjob TimeZone in >=1.27, TZ not found #32

Open kirinnee opened 9 months ago

kirinnee commented 9 months ago

when trying to apply the timeZone field for Kubernetes cronjob kind:

CronJob.batch "helium-scheduler" is invalid: spec.timeZone: Invalid value: "Asia/Singapore": unknown time zone Asia/Singapore

Where can I check the supported timezone or if this feature is available?

timoreimann commented 9 months ago

👋

According to the documentation of the CronJobSpec section, all time zones from this Wikipedia page should work, which includes Asia/Singapore.

I just extended the documented CronJob example by the timeZone field as following:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "* * * * *"
  timeZone: Asia/Singapore
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox:1.28
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

It applies correctly for me:

$ kubectl version
Client Version: v1.28.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.6

$ kubectl apply -f cj.yaml
cronjob.batch/hello created

Are you using the correct API version batch/v1? If so, could you please share the relevant portions of your CronJob manifest?