Score:0

How to trigger k8s Job from different application?

de flag

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?

Score:0
cn flag

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.

dzierzak avatar
de flag
I was thinking about this, but I hoped there is the simpler solution. Thank you for answer.
Rafael Aguilar avatar
fr flag
@dzierzak the sequentially is not part of the nature of K8s declarative fashion, while it provides some notion, for this you would need another layer to do this, for example Argo Workflows would be a perfect match for this.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.