Kubernetes Job Trigger – How to Trigger k8s Job from Different Application

google-cloud-platformgoogle-kubernetes-enginejob-schedulerkubernetes

I will briefly describe my application workflow: I have one application (cronjob), this application read my database and I want to, based on the output from database, run a few jobs in Kubernetes. Sometimes 1 job, sometimes 10 jobs, it depends. Additionally, I would like to pass some env's to this job.

Moreover, I run my Kubernetes Cluster on GCP (Autopilot) so I don't want to have any pod running all the time. So EventListener in Tekton is not a good option since Kubernetes service running the sink logic inside a dedicated Pod.

How Can I do that in the most proper way? Probably I should use K8s API but are there any other options?

Best Answer

The standard way to achieve this would be to provide the rights to create pods, to the service account provided to the cronjob pod.

Then make calls to the Kubernetes API from inside the pod, using kubectl or programatically using a library that can interface with the k8s API.

Related Topic