Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

368
Vistas
Pass current date to kubernetes cronjob

I have a docker image that receive an env var name SINCE_DATE.
I have created a cronjob to run that container and I want to pass it the current date.

How can I do it?

Trying this, I get the literal string date -d "yesterday 23:59"

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my-cron
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: my-cron
            image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
            imagePullPolicy: {{ .Values.image.pullPolicy }}
            env:
            - name: SINCE_DATE
              value: $(date -d "yesterday 23:59")
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could achieve it by overwriting container Entrypoint command and set environment variable. In your case it would looks like:

          containers:
          - name: my-cron
            image: nginx
            #imagePullPolicy: {{ .Values.image.pullPolicy }}
            command:
            - bash
            - -c
            - |
                  export SINCE_DATE=`date -d "yesterday 23:59"`
                  exec /docker-entrypoint.sh           

Note:

Nginx docker-entrypoint.sh in located in / If your image have different path, you should use it, for example exec /usr/local/bin/docker-entrypoint.sh

Very similar use-case can be found in this Stack question

What does this solution?

It will overwrite default script set in the container ENTRYPOINT with the same script but beforehand set dynamically environment variable.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda