【发布时间】:2020-12-01 05:48:21
【问题描述】:
使用 App Engine GAE,我们通常会使用 yaml 来执行不同的 cron 任务,如下所示:
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 时区:澳大利亚/新南威尔士州。 schedule: "*/1 0 0 * * 0" 是正确的表示吗?
我是否必须指定图像,因为网络部署脚本已经指定了图像?
【问题讨论】:
标签: kubernetes cron google-kubernetes-engine