借助App Engine GAE,我们通常会提供具有不同cron任务的yaml,如下所示:
cron:
# Notifications Job
- description: "Remove Notifications Cron Weekly run"
url: /tasks/notifications
schedule: every monday 09:00
timezone: Australia/NSW
# Jobs job
- description: "Remove Deleted Jobs / completed"
url: /tasks/jobs/deleted_completed_drafts
schedule: every monday 09:00
timezone: Australia/NSW
# Marketplace job
- description: "Remove Deleted Products / soldout"
url: /tasks/products/deleted_soldout_drafts
schedule: every monday 09:00
timezone: Australia/NSW
我搬到了GKE,但现在还无法确切地知道如何从一个文件中运行上述cron任务:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: Cron Task
spec:
schedule: "*/1 0 0 * * 0" #"*/1 * * * *"
startingDeadlineSeconds: 104444
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: callout
image: gcr.io/my-site/mysite-kubernetes:v0.0.16
args:
- /bin/sh
- -ec
- curl https://www.ksite.com/tasks/notifications
restartPolicy: Never
那么,如何安排GKE Cron文件来容纳上述所有任务?我必须为每个不同的任务编写不同的代码吗?
时间表应为每个星期一09:00时区:澳大利亚/新南威尔士州。时间表是否正确表示了“ * / 1 0 0 * * 0”?
我是否必须指定图像,导致Web部署脚本已经指定了图像?
我对App Engine不太熟悉,但是
CronJob
时间表:时间基于文档中的kube-controller-manager的时区CronJob
程式与应用程式在同一个丛集中执行,则你无需遍历Loadbalancer,也可以使用类似的服务http://service-name/tasks/notifications
Cronjobs
比尝试将所有三个调用都塞成一个更好。