Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
Run `find` command inside Kubernetes CronJob

Unable to remove files older than one day from the mounted volume. My yaml:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cfs-cleanup
spec:
  concurrencyPolicy: Forbid
  schedule: '0 4 * * *'
  successfulJobsHistoryLimit: 0
  failedJobsHistoryLimit: 10
  jobTemplate:
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 600
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: "false"
        spec:
          restartPolicy: Never
          containers:
            - name: cfs-cleanup
              image: alpine:3.13.2
              command: ["find", "/root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;"]
              volumeMounts:
                - name: cache
                  mountPath: /root/volumes/nginx-cache

          volumes:
            - name: cache
              hostPath:
                path: /root/volumes/nginx-cache
                type: DirectoryOrCreate

the container fails without an error and does nothing. Could it be that command gets executed before volume is mounted?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I'm just guessing, but in your command

command: ["find", "/root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;"]

path /root/volumes/nginx-cache/cfs* won't get expanded.

To verify it, just try command: ["ls", "/root/volumes/nginx-cache/cfs*"]

You can try to wrap your command in sh -c ... like

command: ["sh", "-c", "find /root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;"]

Also, your command is possibly wrong altogether. You merged all arguments of find executable into single string (which shouldn't be problem when invoked via sh -c ....

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda