terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
Timezone specs (CRON_TZ) rejected by kubernetes_cron_job validation
Terraform Version, Provider Version and Kubernetes Version
Terraform version: v0.15.0
Kubernetes provider version: v2.5.0
Kubernetes version: 1.20.10-gke.301
Affected Resource(s)
kubernetes_cron_job
Terraform Configuration Files
resource "kubernetes_cron_job" "demo" {
metadata {
name = "demo"
}
spec {
concurrency_policy = "Replace"
failed_jobs_history_limit = 5
schedule = "CRON_TZ=UTC 1 0 * * *"
starting_deadline_seconds = 10
successful_jobs_history_limit = 10
job_template {
metadata {}
spec {
backoff_limit = 2
ttl_seconds_after_finished = 10
template {
metadata {}
spec {
container {
name = "hello"
image = "busybox"
command = ["/bin/sh", "-c", "date; echo Hello from the Kubernetes cluster"]
}
}
}
}
}
}
}
Debug Output
N/A. The provider works great normally, but the validation step in terraform plan rejects cronspecs with CRON_TZ
Steps to Reproduce
terraform plan
Expected Behavior
K8s cron jobs allow the timezone to be specified with an optional CRON_TZ= prefix (https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax)
The provider should plan to configure/create the cron job with the provided cronspec.
Actual Behavior
The cronspec is rejected at the validation stage here: https://github.com/hashicorp/terraform-provider-kubernetes/blob/8a2911f07b773e6208b0d8a090d520ee7cdd5b88/kubernetes/schema_cron_job_spec.go#L84
Terraform plan errors out with this:
Error: 'spec.0.schedule' should be an valid Cron expression
Deleting the CRON_TZ= bit makes the provider accept the cronspec.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Thanks for opening this @sarneaud – there should be a fix for this merging soon.
Please could we get some movement on that PR.
Can we please get some update on the PR. The CRON_TZ is still not accepted by the provider
From what I read kubernetes will support spec.timeZone on 1.24 version. Cronjob Time Zones.
Will it be supported by the Terraform Kubernetes provider in future versions?
Thank you for opening this issue! After seeing the cronjob documentations from @rafagsiqueira, we'll be looking into adding the new timezone attribute instead of including timezone as part of schedule since it is not planned to be part of schedule in the future.