将日期命令作为参数传递给kubernetes cronjob [英] Pass date command as parameter to kubernetes cronjob

查看:122
本文介绍了将日期命令作为参数传递给kubernetes cronjob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to execute data migration through Kubernetes cronjob using Luigi pipeline. My luigi task receives --start parameter which I want to pass through cronjob command.

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任务.

The cronjob cannot recognize the $(date +%Y-%m-%dT%H) as a bash script and pass this command as string to the luigi task.

推荐答案

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

I am not sure what are you going to archive, but this should work:

      - command:
        - sh
        - -c
        - 'exec luigi --module module.task Migrate10Days --start $(date +%Y-%m-%dT%H) --workers --workers'

这篇关于将日期命令作为参数传递给kubernetes cronjob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆