I am trying to build a docker image for python script and created CronJob and deployed it to Kubernetes, but i am not able to see any logs . if i deploy it to a pod i am able to see logs. Kindly let me know if i need to make any changes to Cronjob code. Below are the Docker file and Cronjob code
DockerFile:
from python:3.9-slim-buster
RUN apt-get update && apt-get install build-essential -y
RUN apt install libpq-dev python3-dev -y
RUN pip install --upgrade pip
COPY . /
RUN ls
RUN pip3 install -r ./requirements.txt
RUN mkdir /app/health
RUN chmod +x /app/scripts/main.py
WORKDIR /app
RUN ls
WORKDIR /app/scripts
RUN ls
ENTRYPOINT ["python", "/app/scripts/main.py"]
Deployment[CronJob]
apiVersion: batch/v1
kind: CronJob
metadata:
name: <cronjob name>
namespace: <namespace>
spec:
jobTemplate:
spec:
template:
spec:
containers:
- name: <containername>
image: <imagename>
imagePullPolicy: Always
command: ["/bin/sh"]
args: [python, main.py]
restartPolicy: OnFailure
schedule: "59 6 * * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 0