How can I trigger a Kubernetes Scheduled Job manually?

前端 未结 7 542
抹茶落季
抹茶落季 2020-12-07 13:43

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 t

7条回答
  •  死守一世寂寞
    2020-12-07 14:12

    You can create a simple job based on your ScheduledJob. If you already run a ScheduledJob, there are jobs in history.

    kubectl get jobs
    
    NAME               DESIRED   SUCCESSFUL   AGE
    hello-1477281595   1         1            11m
    hello-1553106750   1         1            12m
    hello-1553237822   1         1            9m
    

    Export one of these jobs:

    kubectl get job hello-1477281595 -o yaml > my_job.yaml
    

    Then edit the yaml a little bit, erasing some unnecessary fields and run it manually:

    kubectl create -f my_job.yaml
    kubectl delete -f my_job.yaml
    

提交回复
热议问题