I would like to create job from cronjob using curl command.
I am aware of kubernetes kubectl or openshift oc commands. The following command works. But I am looking for curl command.
Kubernetes: kubectl create job --from=cronjob/
OpenShift oc create job --from=cronjob/
Please help. I am using OpenShift 3.11.
You can run the kubectl command with high verbosity level and it should show the curl command and the request body which is internally being used.
kubectl create job --from=cronjob/test-job --v=10
I0324 10:46:36.071067   44400 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json" -H "User-Agent: kubectl/v1.17.0 (darwin/amd64) kubernetes/70132b0" 'https://127.0.0.1:32768/apis/batch/v1beta1/namespaces/default/cronjobs/test-job'
I0324 10:46:36.110550   44400 round_trippers.go:443] GET https://127.0.0.1:32768/apis/batch/v1beta1/namespaces/default/cronjobs/test-job 200 OK in 39 milliseconds
I0324 10:46:36.110573   44400 round_trippers.go:449] Response Headers:
I0324 10:46:36.110579   44400 round_trippers.go:452]     Content-Type: application/json
I0324 10:46:36.110585   44400 round_trippers.go:452]     Content-Length: 898
I0324 10:46:36.110590   44400 round_trippers.go:452]     Date: Tue, 24 Mar 2020 05:16:36 GMT
I0324 10:46:36.110631   44400 request.go:1017] Response Body: {"kind":"CronJob","apiVersion":"batch/v1beta1","metadata":{"name":"test-job","namespace":"default","selfLink":"/apis/batch/v1beta1/namespaces/default/cronjobs/test-job","uid":"11813788-123d-4379-a103-79e18c7e954c","resourceVersion":"64182","creationTimestamp":"2020-03-24T05:16:03Z"},"spec":{"schedule":"*/1 * * * *","concurrencyPolicy":"Allow","suspend":false,"jobTemplate":{"metadata":{"name":"test-job","creationTimestamp":null},"spec":{"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":[{"name":"test-job","image":"busybox","resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"Always"}],"restartPolicy":"OnFailure","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{},"schedulerName":"default-scheduler"}}}},"successfulJobsHistoryLimit":3,"failedJobsHistoryLimit":1},"status":{}}
I0324 10:46:36.117139   44400 request.go:1017] Request Body: {"kind":"Job","apiVersion":"batch/v1","metadata":{"name":"job","creationTimestamp":null,"annotations":{"cronjob.kubernetes.io/instantiate":"manual"},"ownerReferences":[{"apiVersion":"apps/v1","kind":"CronJob","name":"test-job","uid":"11813788-123d-4379-a103-79e18c7e954c","controller":true,"blockOwnerDeletion":true}]},"spec":{"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":[{"name":"test-job","image":"busybox","resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"Always"}],"restartPolicy":"OnFailure","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{},"schedulerName":"default-scheduler"}}},"status":{}}
I0324 10:46:36.117189   44400 round_trippers.go:423] curl -k -v -XPOST  -H "Accept: application/json, */*" -H "Content-Type: application/json" -H "User-Agent: kubectl/v1.17.0 (darwin/amd64) kubernetes/70132b0" 'https://127.0.0.1:32768/apis/batch/v1/namespaces/default/jobs'