gpt4 book ai didi

kubernetes - 在cron作业kubernetes上运行命令时出错

转载 作者:行者123 更新时间:2023-12-02 12:05:43 25 4
gpt4 key购买 nike

我正在尝试在我的kubernetes集群中设置cronjobs,我具有将其他API的数据导入到数据库的微服务。我想每10分钟运行一次此命令。我有以下cronjob list

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旋转Pod时出现以下错误

Could not open input file: artisan bulk:import



如何解决呢?

最佳答案

假设存在artisan文件,并且php可以执行该文件:

command: ["/usr/local/bin/php"]
args: ["artisan", "bulk:import"]

这样,将有两个参数传递给php,而不是php假定要执行的文件。

关于kubernetes - 在cron作业kubernetes上运行命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53390542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com