[英]Running cron job from K8S cluster
I need to run a third part API in schedulded interval from k8s cluster.我需要在 k8s 集群的预定时间间隔内运行第三方 API。 I have tried with k8s corn job but its not working getting error as invalid command .
我曾尝试使用 k8s 玉米作业,但它不起作用,因为命令无效而出错。 I am using below script.
我正在使用以下脚本。 Can anyone suggest how to use it
任何人都可以建议如何使用它
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: corn-job
namespace: scheduler
spec:
schedule: "5 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c curl http://google.com
restartPolicy: OnFailure
busybox image doesnt have curl binary. busybox 图像没有 curl 二进制文件。 it wont work.
它不会工作。 use the below yaml or update the image
使用下面的 yaml 或更新图像
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cron-demo
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: ekambaram/curl
command: ["curl"]
args: ["http://google.com"]
restartPolicy: OnFailure
just tested it and find below the output刚刚测试它并在输出下方找到
master $ kubectl get po
NAME READY STATUS RESTARTS AGE
corn-job-1574850360-srwf6 0/1 Completed 0 44s
master $ kubectl logs -f corn-job-1574850360-srwf6
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
100 219 100 219 0 0 39 0 0:00:05 0:00:05 --:--:-- 54
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.