I've created a Kubernetes Scheduled Job, which runs twice a day according to its schedule. However, I would like to trigger it manually for testing purposes. How can I do this?
相关问题
- Microk8s, MetalLB, ingress-nginx - How to route ex
- How do I change the storage class of existing pers
- Use awslogs with kubernetes 'natively'
- Kubernetes coredns readiness probe failed
- Default certificate on Nginx-ingress
相关文章
- k8s 访问Pod 时好时坏
- Override env values defined in container spec
- How do I create a persistent volume claim with Rea
- How to obtain the enable admission controller list
- Difference between API versions v2beta1 and v2beta
- MountVolume.SetUp failed for volume “nfs” : mount
- How to save content of a configmap to a file with
- GKE does not scale to/from 0 when autoscaling enab
EDIT - July 2018: see @pedro_sland's answer as this feature has now been implemented
My original answer below will remain correct for older versions of kubectl less than v1.10.1
========================================================================
Aside from creating a new job (as the other answers have suggested), there is no current way to do this. It is a feature request in with kubernetes now that can be tracked here: https://github.com/kubernetes/kubernetes/issues/47538
The issue #47538 that @jdf mentioned is now closed and this is now possible. The original implementation can be found here but the syntax has changed.
With kubectl v1.10.1+ the command is:
kubectl create job --from=cronjob/<cronjob-name> <job-name>
It seems to be backwardly compatible with older clusters as it worked for me on v0.8.x.
I've created a small cmd utility for convenience to do just that and also suspend and unsuspend cronjobs.
https://github.com/iJanki/kubecron
Unfortunately, none of the example syntax above works in Google Kubernetes Engine (GCP). Also, the GKE docs themselves are wrong. :(
In Kubernetes
1.10.6.gke-2
, the working syntax isYou can create a simple job based on your ScheduledJob. If you already run a ScheduledJob, there are jobs in history.
Export one of these jobs:
Then edit the yaml a little bit, erasing some unnecessary fields and run it manually:
If you want to test the job, create a Job config from your Cron Job (ScheduledJob) config and run it manually using the following command: