将日期命令作为参数传递给kubernetes cronjob

时间:2019-08-05 18:47:09

标签: kubernetes cron luigi

我想使用Luigi管道通过Kubernets cronjob执行数据迁移。我的luigi任务收到了我想通过cronjob命令传递的--start参数。

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: migration
spec:
  schedule: "0 0 */1 * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: spark
          containers:
          - name: migratecronjob
            image: latest-image
            imagePullPolicy: Always
            env:
              - name: TAG
                value: latest-image
              - name: MIGRATION_TAG
                value: migration-v05
            command:
              -  "luigi"
              - "--module" 
              - "module.task" 
              - "Migrate10Days"
              - "--start"
              - $(date +%Y-%m-%dT%H)
              - "--workers"
              - "10"
          restartPolicy: OnFailure

cronjob无法将$(date +%Y-%m-%dT%H)识别为bash脚本,无法将此命令作为字符串传递给luigi任务。

1 个答案:

答案 0 :(得分:2)

我不确定您要归档什么,但这应该可行:

(tag1 <> tag2 or tag1 is null or tag2 is null) and
(tag1 <> tag3 or tag1 is null or tag3 is null) and
. . .
-- there are lots of combinations so give yourself some time