我正在尝试在我的kubernetes集群中设置cronjobs,我具有将其他API的数据导入数据库的微服务。我想每10分钟运行一次此命令。我有以下cronjob清单
apiVersion: v1
items:
- apiVersion: batch/v1beta1
kind: CronJob
metadata:
labels:
chart: cronjobs-0.1.0
name: cron-cronjob1
namespace: default
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
app: cron
cron: cronjob1
spec:
containers:
command: ["/usr/local/bin/php"]
args: ["artisan bulk:import"]
env:
- name: DB_CONNECTION
value: postgres
- name: DB_HOST
value: postgres
- name: DB_PORT
value: "5432"
- name: DB_DATABASE
value: xxx
- name: DB_USERNAME
value: xxx
- name: DB_PASSWORD
value: xxxx
- name: APP_KEY
value: xxxxx
image: registry.xxxxx.com/xxxx:2ecb785-e927977
imagePullPolicy: IfNotPresent
name: cronjob1
ports:
- containerPort: 80
name: http
protocol: TCP
imagePullSecrets:
- name: xxxxx
restartPolicy: OnFailure
terminationGracePeriodSeconds: 30
schedule: '* * * * *'
successfulJobsHistoryLimit: 3
cronjob Scheduler旋转吊舱时出现以下错误
无法打开输入文件:artisan bulk:import
如何解决这个问题?
答案 0 :(得分:1)
假设文件artisan
存在并且php
可以执行它:
command: ["/usr/local/bin/php"]
args: ["artisan", "bulk:import"]
这样,将有两个参数传递给php,而不是php假定要执行的参数。
答案 1 :(得分:0)
这是解决方法
args:
- "/bin/bash"
- "-c"
- "/var/www/html/artisan bulk:import"