我需要在k8s集群的预定间隔内运行第三方API。我已经尝试过用k8s玉米工作,但是由于无效命令,它无法正常工作。我正在使用以下脚本。谁能建议如何使用它
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
答案 0 :(得分:2)
busybox图片没有卷曲二进制文件。它不会工作。使用下面的Yaml或更新图片
String input = "MyPrefix_CH-DE_ProductName.pdf";
String[] segments = input.split("_");
String prefix = segments[0];
String countryCode = segments[1].split("-")[0];
String languageCode = segments[1].split("-")[1];
String fileName = segments[2].substring(0, segments[2].length() - 4);
System.out.println("prefix " + prefix);
System.out.println("countryCode " + countryCode);
System.out.println("languageCode " + languageCode);
System.out.println("fileName " + fileName);
刚刚对其进行了测试,并在输出下方找到
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