Kubernetes cronjob没有文件或目录,但它在docker镜像中



有一个kubernetes cronjob的问题,当它运行时,它说/usr/share/nginx/html不是一个目录,"没有这样的文件或目录",但它肯定是,它被嵌入到图像中,如果我直接在docker上加载图像,文件夹肯定在那里。

这里是yaml:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: php-cron
spec:
jobTemplate:
spec:
backoffLimit: 2
activeDeadlineSeconds: 1800
completions: 2
parallelism: 2
template:
spec:
containers:
- name: php-cron-video
image: my-image-here
command:
- "cd /usr/share/nginx/html"
- "php bin/console processvideo"
volumeMounts:
- mountPath: /usr/share/nginx/html/uploads
name: uploads-volume
- mountPath: /usr/share/nginx/html/private_uploads
name: private-uploads-volume
restartPolicy: Never
volumes:
- name: uploads-volume
hostPath:
path: /data/website/uploads
type: DirectoryOrCreate
- name: private-uploads-volume
hostPath:
path: /data/website/private_uploads
type: DirectoryOrCreate
schedule:  "* * * * *"

docker run -it --rm my-image-here bash

直接加载到/usr/share/nginx/html文件夹

这是怎么回事?相同的映像和正常部署一样可以正常工作。

假设您的图像确实有/usr/share/nginx/html/bin,尝试将command更改为:

...
command: ["sh","-c","cd /usr/share/nginx/html && php bin/console processvideo"]
...

相关内容

  • 没有找到相关文章

最新更新