Home > front end >  Kubernetes cronjob no file or directory but it's in the docker image
Kubernetes cronjob no file or directory but it's in the docker image

Time:05-24

Having an issue with a kubernetes cronjob, when it runs it says that /usr/share/nginx/html is not a directory, "no such file or directory", yet it definitely is, it's baked into the image, if i load the image up straight on docker the folder is definitely there.

Here is the 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

Loads up straight into the /usr/share/nginx/html folder

What's going on here? The same image works fine as well as a normal deployment.

CodePudding user response:

Assumed your image truly has /usr/share/nginx/html/bin baked in, try changed the command to:

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