kubernetes: Updated CronJob Schedule Missing from Dry Run

What happened: When trying to update a CronJob schedule using a combination of kubectl apply --dry-run and kubectl replace, the schedule is not updated. The schedule emitted from kubectl apply --dry-run does not reflect the updated schedule but rather the original schedule.

What you expected to happen:

I expected that kubectl apply --dry-run would reflect the updated schedule from the YAML manifest.

How to reproduce it (as minimally and precisely as possible):

$ cat my-cronjob.yaml | grep schedule:
    schedule: "0 5 * * *"
$ cat my-cronjob.yaml | kubectl apply -f -
cronjob.batch "my-cronjob" created

$ sed -i 's/5/7/g' my-cronjob.yaml
$ cat my-cronjob.yaml | grep schedule:
    schedule: "0 7 * * *"
$ cat my-cronjob.yaml | kubectl apply -o yaml --dry-run -f -  | grep schedule:
    schedule: "0 5 * * *"

$ kubectl delete cronjob my-cronjob
cronjob.batch "my-cronjob" deleted
$ cat my-cronjob.yaml | kubectl apply -o yaml --dry-run -f -  | grep schedule:
    schedule: "0 7 * * *"

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
    • Client Version: v1.10.7
    • Server Version: v1.10.11-gke.1
  • Cloud provider or hardware configuration:
    • GKE
  • OS (e.g. from /etc/os-release):
    • Ubuntu 16.04.5 LTS
  • Kernel (e.g. uname -a):
    • 4.15.0-43-generic
  • Install tools:
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

This is a kubectl issue. /remove-sig apps /sig cli