kuberneteskubernetes-cronjob

Why can't I specify a container name when using imperative command to create cronjob in k8s?


I'm trying to run a command to create cronjob:

"k create cronjob mycron --image:httpd --schedule="*/8 * * * *" --name=mycontainer-name"

but it does not recognize, I tried to use flag "--container-name=mycontainer-name" but that's not working too.

Is there way to do a one-liner and specify a container name in it? Or is the only way to use declarative like:

"k create cronjob mycron --image:httpd --schedule="*/8 * * * *" --dry-run=client -oyaml > d.yaml"

and then change it in yaml file and run apply?


Solution

  • I don't think CLI supports any Options to name container. You can check kubectl create cronjob --help for all the available options. kubectl apply seems to be the only possible way.