Issue
I need to create a Cronjob in Kubernetes that monitors a "tbl_scheduled_upgrades" table and sends a notification whenever the "scheduled_date" column is in two weeks. I already have 3 cronjobs made by someone as yaml/python files. Any idea how to make it?
Solution
Python file is the code file where your logic will goes for cronjob.
While you can use same YAML file for ref to update name :
& image:
to it and apply it it will create the cronjob for you.
You write your code query and connection logic into python to create the docker image. Use docker image into the same YAML file that you have as ref and update the values and apply.
You can more about the cronjob at :https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
YAML cron example
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: <Python docker image URL>
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
you can update the docker image URL and other details as per need.
Answered By - Harsh Manvar Answer Checked By - Terry (WPSolving Volunteer)