File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ apiVersion : batch/v1beta1
2
+ kind : CronJob
3
+ metadata :
4
+ name : training-job-cron
5
+ spec :
6
+ schedule : " */1 * * * *"
7
+ jobTemplate :
8
+ spec :
9
+ template :
10
+ spec :
11
+ containers :
12
+ - name : training-job-cron
13
+ image : busybox
14
+ command : ['sh', '-c', 'date; echo Hello from the Kubernetes cluster']
15
+ restartPolicy : OnFailure
Original file line number Diff line number Diff line change @@ -66,3 +66,13 @@ kubectl create -f ./job-parallel-queue.yaml
66
66
jobsArray=($(echo $(kubectl get pods --show-all --selector=job-name=training-job-parallel --output=jsonpath={.items..metadata.name}) | tr ' ' '\n'))
67
67
kubectl logs ${jobsArray[1]}
68
68
kubectl logs ${jobsArray[2]}0
69
+
70
+ ### cron job ###
71
+ kubectl create -f ./job-cron.yaml
72
+ kubectl get cronjob training-job-cron
73
+ # this will create a cronjob which is going to create a job in every minute
74
+ # if you want to see the logs of a job: get jobs, select one from the cron, find its pod and log it
75
+ # kubectl get jobs
76
+ # pod=$(kubectl get pods -a --selector=job-name=training-job-cron-1516207920 --output=jsonpath={.items..metadata.name})
77
+ # kubectl logs $pod
78
+ kubectl delete cronjob hello
You can’t perform that action at this time.
0 commit comments